public function execute()
 {
     if ($this->getOption('error')) {
         $this->error('CRASHTEST: error', true);
     }
     if ($this->getOption('exception')) {
         throw new Exception('CRASHTEST: uncaught exception');
     }
     if ($this->getOption('fatal')) {
         $this->error('CRASHTEST: fatal');
         $everything_and_nothing = FOO::BAR();
     }
     $this->error('CRASHTEST: should not reach this line.');
 }
<?php

function __autoload($class)
{
    if ($class != "FOO") {
        throw new Exception("wrong class name!");
    }
    class FOO
    {
        public function success()
        {
            echo "success";
        }
    }
}
$c = new FOO();
$c->success();
Example #3
0
    public static $my_static = 'foo';
    public function staticValue()
    {
        return self::$my_static;
    }
    public static function myStaticFunction()
    {
        return self::$my_static;
    }
}
class Bar extends Foo
{
    public function fooStatic()
    {
        return parent::$my_static;
    }
}
print Foo::$my_static . "\n";
$foo = new Foo();
print $foo->staticValue() . "\n";
print $foo->my_static . "\n";
// "Propriété" my_static non définie
print FOO::myStaticFunction();
print $foo->myStaticFunction();
print $foo::$my_static . "\n";
$classname = 'Foo';
print $classname::$my_static . "\n";
// Depuis PHP 5.3.0
print Bar::$my_static . "\n";
$bar = new Bar();
print $bar->fooStatic() . "\n";
<?php

function __autoload($class)
{
    if ($class != "FOO") {
        throw new Exception("wrong class name!");
    }
    class FOO
    {
        public static function success()
        {
            echo "success";
        }
    }
}
FOO::success();