[ create a new paste ] login | about

Link: http://codepad.org/AusqEWlS    [ raw code | output | fork ]

PHP, pasted on Jan 7:
<?php

class obj1 {

    public function method1() {
        return new obj2;
    }

    public function method3() {
        return $this;
    }

    public function method4() {
        print "obj1 method 4 run";
    }

}

class obj2 {

    public function method2() {
        print "obj2 method 2 run\n";
    }

}

$obj = new obj1;
$obj->method1()->method2();
$obj->method3()->method4();

?>


Output:
1
2
obj2 method 2 run
obj1 method 4 run


Create a new paste based on this one


Comments: