function test() { A::test1(1, 'a'); B::test2(1, 'a'); self::test3(1, 'a'); parent::test4(1, 'a'); }
<?php class A { function test1(&$farg1) { $farg1 = 1.5; } } class B { static function test2(int &$farg2) { } } function test3(&$farg3) { } $a = new A(); $arg1 = [1, 2, 3]; $a->test1($arg1); B::test2($arg1); // No errors from undefined vars since they are by-ref test3($arg3); preg_match("/(a)/", "a", $match);
public static function test3() { echo self::NAME, "\n"; forward_static_call(array('A', 'test')); } } class C extends B { const NAME = 'C'; public static function test() { echo self::NAME, "\n"; forward_static_call(array('A', 'test')); } } A::test(); echo "-\n"; B::test(); echo "-\n"; B::test2(); echo "-\n"; B::test3(); echo "-\n"; C::test(); echo "-\n"; C::test2(); echo "-\n"; C::test3(); ?> ===DONE===
<?php class A { private $_attr1 = 123; protected $_attr2 = 456; public $attr3 = 789; public static $attr4 = 'abc'; public function test() { echo $this->_attr1, "\n"; echo $this->_attr2, "\n"; } } class B extends A { public function test2() { echo $this->_attr1, "\n"; echo $this->_attr2, "\n"; } } $a = new A(); $b = new B(); $a->test(); echo $a->attr3, "\n"; $b->test2(); echo $b->attr3, "\n"; A::$attr4 = 'def'; echo B::$attr4, "\n";