Looking Ahead to PHP 6

This is my look at what’s planned for the forthcoming revision to the PHP language. Removal of Deprecated Features PHP 6 includes a lot of tidying up, removing features of the language that have caused annoyance, confusion and security headaches. Although these changes are too numerous to list here, and the list will probably change […]

Read More…

TrivialEncoder/0.2

An update to my PHP encryption class. Despite the name, it's becoming a pretty sophisticated encyption machine. New encryption algorithms added: Vigenerè cypher One-Time Pad Bruce Schneier's Superencyption Various other methods using the MCrypt library The TrivialEncoderManager class has been obsoleted by TE_Machine, an abstract class with several different child classes for encoding, decoding and […]

Read More…

PHP Debugging with Style -OR- How I Learned to Stop Worrying and Love the Bug

PHP lets you define your own error handler, so I decided to get a bit fancy. MegaErrorHandler (MEH) outputs its errors as specially-formatted HTML comments, with the details of the error encoded using JSON. A small client-side script, with an associated stylesheet then pulls this data out of the comments and formats it as a […]

Read More…

Parsing an HTML Table with PEAR’s XML_HTMLSax3

Here’s an example of how to parse an HTML table into an array using the PEAR module XML_HTMLSax3. It supports the , and elements and the rowspan and colspan attributes. It’s worth noting that this code will raise a bunch of notices if you run it displaying all errors. This is pretty difficult to avoid, […]

Read More…

PHP Domain Class

On Usenet an often-asked question is how to programmatically determine the “domain” of a particular hostname. That is, excluding the components traditionally thought of as subdomains. As an example, groups.google.com and www.google.com both have a domain of google.com. Invariably, one answer comes back stating that you just need to chop off everything from the front, […]

Read More…

PHP Linkifier

Here’s a nifty bit of code I wrote a while back (utilising a function from PHP SmartyPants) that takes a bunch of HTML, searches it for some word or phrase that you specify, and turns all occurances of it into a link, unless it’s already a link! […]

Read More…

PHP vs Perl

Here's a simple program which calculates, to eight decimal places, the value of the Golden Ratio φ implemented in both PHP and Perl, to demonstrate their similarities. Perl #!/usr/bin/perl $a = 1; $b = 1; $c = undef; $psi_old = undef; print “Approximating psi…\n”; while (1) { $psi = sprintf(‘%.08f’, $b/$a); last if ($psi_old eq […]

Read More…