[php] archive category


PHP4 passed away today. It was old and stinky and had to go.

I’m still working through my emotions right now.

Dead but kinda hot

MeeboMaker: for valid XHTML Meebo Widgets

Valid HTML Meebo Widgets with MeeboMakerMeebo is a web-based instant messaging client that allows users to integrate their instant message clients into one easy-to-use web interface. Rather than chatting from the MSN, AIM or Yahoo desktop clients, Meebo allows you to chat from a lightweight Ajax interface. You can also generate Meebo widgets that allow IM interaction from web sites or blogs.

The problem is that the code generated by Meebo’s widget factory is non-valid XHTML. This can be a problem for people who build web sites that require valid HTML. The Meebo widget factory produces a Flash container based on the embed tag which is not part of the XHTML 1.0 Transitional specification. I was able to build a valid container based on the object tag which will pass automatic validation.

Rather than get into the messy details, I have created a simple application that extracts the important bits of information from the embed tag and builds a new object tag. It is still kind of temperamental, but it works well as long as you don’t try to feed it bad code. Give MeeboMaker a try and let me know what you think.

Testing for GD and PEAR

I was making a module the other day that had some dependencies on PEAR and GD. So I cobbled together a test for GD and PEAR from some GPL‘d code I found online. I thought that I’d share the code snips (it is all GPL licensed code by the way).

The PHP Extension and Application Repository is a standard library of reusable PHP components.
The GD library is an image manipulation library that can be used with PHP

Checking for GD in PHP

 * check if GD is installed and is version 2 or higher
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
if (! extension_loaded('gd')) {
    echo "The GD extension was not found!";
} else {
    if (function_exists('gd_info')) {
        // use gd_info if possible...
        $gd_ver_info = gd_info();
        preg_match('/\d/', $gd_ver_info['GD Version'], $match);
        if ($match[0] < 2) {
            echo "This program needs GD version 2 or higher to run properly.";
    } else {
        // ...otherwise use phpinfo().
        $info = ob_get_contents();
        $info = stristr($info, 'gd version');
        preg_match('/\d/', $info, $match);
        if ($match[0] < 2) {
            echo "This module requires the GD Library version 2 or higher.";

Checking for PEAR in PHP

 * check if PEAR is installed
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
if (!class_exists('PEAR') || !(@include 'PEAR.php')) {
	echo "This module requires the PEAR Library.";