Exemple #1
0
class foo
{
    private function a()
    {
        var_dump(1);
    }
    public function b()
    {
        var_dump(2);
    }
    protected function c()
    {
        var_dump(3);
    }
    static function __callstatic($a, $b)
    {
        var_dump('__callStatic::' . $a);
    }
    public function __call($a, $b)
    {
        var_dump('__call::' . $a);
    }
}
$x = new foo();
$x->a();
$x->b();
$x->c();
$x::a();
$x::b();
$x::c();
Exemple #2
0
class foo
{
    public $x = 2;
    public function a()
    {
        $x = array();
        $x[] = new foo();
        return $x;
    }
    public function b()
    {
        return array(1.2, array(new self()));
    }
    public function c()
    {
        $a = array();
        $b =& $a;
        $b[] = true;
        return $a;
    }
    public function d()
    {
        return $this->b();
    }
}
$foo = new foo();
var_dump($foo->a()[0]->x);
var_dump($foo->a()[0]);
var_dump($foo->b()[1][0]->a()[0]->x);
var_dump($foo->c()[0]);
var_dump($foo->d()[0]);
Exemple #3
0
<?php

error_reporting(E_ALL);
class foo
{
    public $x = array();
    public function b()
    {
        return $this->x;
    }
    public function c()
    {
        return $x;
    }
    public static function d()
    {
    }
}
$foo = new foo();
$foo->b()[0] = 1;
$foo->c()[100] = 2;
foo::d()[] = 3;
print "ok\n";