PHP Autoload

May 30, 2009 No comments yet

In large PHP applications you typically see a “classes” directory that only contains classes which are used throughout the application (database, session management, forms etc..). A problem quickly appears: Everytime you wanted to use one of the classes, you would be forced to include() it at the top of the page. __autoload() solves this by automatically including the definition file when a…

Securing User Input in PHP

April 21, 2008 2 comments

In nearly all of my PHP tutorials you’ll see me using the secure function to sanitise incoming user data from things like forms, and $_GETs . Its a small function, which no doubt alot of you already have, but here it is anyway.

function secure($string) {
		$string = strip_tags($string);
		$string = htmlspecialchars($string);
		$string = trim($string);
		$string = stripslashes($string);
		$string = mysql_real_escape_string($string);…