In PHP 4 constructors were supported by creating a function with the same name as the class.

<?php
class foo {
    var 
$bar;
    function 
foo($val) { $this->bar $val; }
}
?>
In PHP 5, the __construct() method will be called (if it exists) when the object is created, and the __destruct() method when it is destroyed.

<?php
class foo {
    var 
$bar;

    function 
__construct($val) {
        
$this->bar $val;
    }

    function 
__destruct() {
        unset(
$this->bar);
    }
}
?>