Objects

Object Initialization

To initialize an object, you use the new statement to instantiate the object to a variable.


<?php
class foo {
    function do_foo() { 
        echo "Doing foo."; 
    }
}

$bar = new foo;
$bar->do_foo();
?>
      

For a full discussion, please read the section Classes and Objects.ive indices) $a["foo"][4]["bar"][0] = $f; # four dimensional!

In PHP 3 it is not possible to reference multidimensional arrays directly within strings. For instance, the following will not have the desired result:

 
$a[3]['bar'] = 'Bob';
echo "This won't work: $a[3][bar]";
      

In PHP 3, the above will output This won't work: Array[bar]. The string