Simon Willison’s Weblog

Subscribe

PHP5 info from Sterling Hughes

23rd March 2003

Sterling Hughes has posted the slides he will be using for his presentation on PHP 5 next week. They provide a great deal of insight in to the new additions to look forward to in PHP 5, including a few I hadn’t heard about before.

One of the most instantly useful looking is Class Autoloading. By creating a function called __autoload() you can add logic to automatically include a class the first time it is called. The example code explains this much better:


<?php
function __autoload($classname) {
    include_once("$classname.php");
}
$mono = new monkey;
$mono->scratch();
?>

PHP 5 will also feature support for class access control, interfaces and type hinting where a function or method can declare the type it expects for each of its arguments. It’s sounding more and more like Java all the time, but seeing as all of the new support for stricter control are optional I don’t see this as a disadvantage at all. Coders who want serious OOP can have it, while people knocking out a quick script don’t need to worry about them at all.

This is PHP5 info from Sterling Hughes by Simon Willison, posted on 23rd March 2003.

Next: UltraEdit regular expressions

Previous: coWiki uses PHP5

Previously hosted at http://simon.incutio.com/archive/2003/03/23/php5InfoFromSterlingHughes