PHP5 fixed

Oh goody, the problem I was having building PHP 5.0 RC2 seems to have been fixed. I can go back to experimenting again.

Continue reading “PHP5 fixed”

Testing PHP in entries

Just testing MT to see if it will allow me to do code in entries.

Inspired by a thread on the MovableType support forum, I want to see if I can display a text string as an image inside a blog entry.

It works! Well, it used to work until something broke on the server…

Nothing terribly complicated, but the ability to use PHP inside a blog entry does have some interesting potential.

For those of you interested in seeing what I did, I just embedded the following in my entry

$text = date("F j, Y, g:i a");
echo "<p>Today's date: $text</p>\n";
// Set the image size based on the font size and text
$font = 8;
$width  = ImageFontWidth($font) * strlen($text);
$height = ImageFontHeight($font);
// Create the image object
$im = imagecreate($width,$height);
// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// write the string at the top left
imagestring($im, 5, 0, 0, $text, $textcolor);
// output the image
// write the image to a file
// Change /path/to/image/dir/ to whatever path you're using
if (is_writable("/path/to/image/dir/")) {  // Check to see if the directory is writable
imagepng($im,"test.png",75);
echo "<p>Today's date as an image: <img src=\"test.png\"  height=\"$height\" width=\"$width\" /></p>\n";
}
else echo "<p>Don't have permission to write to the current directory</p>\n";
imagedestroy($im);