Muffinresearch Labs by Stuart Colville

Prevent ampersands breaking validation | 0 Comments

Posted in Code on 1st June 2004, 10:15 pm by

When you have toiled to build a site that follows current web standards, it can be a real shame when adding a PHP script you find that validation gets broken.

One particular problem is where PHP functions create urls (addresses) that contain the “&” or ampersand.

To stop this from holding back an otherwise perfectly formed piece of XHTML you can use a little trick to make PHP use the html entity for the ampersand character.

Add the following to your script’s config file or anywhere that it will be included on everypage that creates sessions.

ini_set('arg_separator.ouput', '&');

Now the urls are created using the entity for ampersands and your script will now be compliant with XHTML 1.0.

Now that has got you started you can take into consideration other php.ini over-rides possible with the ini_set() function.

Post Tools

GNU screen: open tab in current working directory|(1)

A nice trick for having screen open a new tab in the same directory as the one you’re currently in. To use it add it to your .screenrc

# Open new window in current dir.
bind c stuff "screen -X chdir \$PWD;screen^M"
bind ^c stuff "screen -X chdir \$PWD;screen^M"

Hat tip: mteckert on SuperUser.com

Ubuntu: add-apt-repository: command not found|(2)

When you’re using a minimal Ubuntu install if you find the ‘add-apt-repository’ command is missing (it’s useful for adding PPAs and other repositories), then simply run:

sudo apt-get install python-software-properties

Photos on Flickr

© Copyright 2004-12 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.517s.