Skip to main content

Posts

Showing posts from August 25, 2008

PHP OOP

New Functionality Support for PPP Exceptions Object Iteration Object Cloning Interfaces Autoload And much more, and it is faster too! The Basics The basic object operations have not changed since PHP 4. class my_obj { var $foo; function my_obj() { // constructor $this->foo = 123; } function static_method($a) { return urlencode($a); } } $a = new my_obj; // instantiate an object $a->my_obj(); // method calls my_obj::static_method(123); // static method call Similar, but not the same. While the syntax remains the same, internals are quite different.  Objects are now always being passed by reference, rather then by value. PHP 5 $a = new foo(); == PHP4 $a = &new foo(); While the old style constructors are supported, new more consistent mechanism is available. __construct() method. PPP Annoyance The VAR keyword for identifying class properties became deprecated and will throw an E_STRICT warning. PHP Strict Standards: var: Deprecated. Please ...