Make text PHP safe

Posted on December 21, 2006 on 2:20 pm by glen | In General, PHP | 1 Comment

Have you ever copied and pasted some text from somewhere for use in a PHP string? You have? Well, you know that there can be some problems if the text contains single or double quotes. That’s where this little tool will come in handy:

PHP String Quoter

Just enter your text, and it will return a version of it ready to use in either single or double quoted PHP strings.

Enabling GD library for PHP 4.4.4 on Mac OS X

Posted on December 16, 2006 on 2:21 am by glen | In MySQL, PHP, Apache, Mac | 4 Comments

For some reason, GD is not enabled in the default Mac OS X build of PHP 4.4.4. Here’s an easy way to install. Make sure you have the following fink packages installed:

  • libpng3
  • libjpeg

1. Download the source code for PHP 4.4.4

PHP 4.4.4 source

2. Unpack the source

tar jxvf php-4.4.4.tar.bz2
cd php-4.4.4

3. Compile and install the GD extension


cd ext/gd
phpize
./configure --with-jpeg-dir=/sw --with-png-dir=/sw --with-zlib-dir=/usr
make
sudo make install

This last stage will install the GD shared object into /usr/lib/php/extensions/no-debug-non-zts-20020429/

4. Pull in the GD module at startup

Edit /etc/php.ini and add the following line:

; Enable gd extension module
extension=gd.so

and make sure the following line is commented out:

;extension_dir = "./"

5. Restart Apache

sudo apachectl graceful

Bingo!

GD info

PHP syntax check on Save

Posted on December 7, 2006 on 10:29 am by glen | In PHP, Mac | No Comments

John Gruber has produced a nice little AppleScript to check your PHP documents for syntax errors. I have found that you can use this as a nice safety net so not to save any PHP documents with errors by attaching the script to the Save option in the File menu:

1. Install the AppleScript into ~/Library/Application Support/BBEdit/Scripts/
2. Make an Alias to this script and name it File•Save You can get the round character between File and Save by holding the option key and pressing 8.
3. Move this Alias to ~/Library/Application Support/BBEdit/Menu Scripts/
4. Restart BBEdit

Now, whenever you try and save a PHP script, it will perform a syntax check. If there are any problems, then it will tell you what line number the problem has occurred on, which you can then fix. Useful, yes?

Feeds: Entries | Comments