Example #1
0
 function test()
 {
     A::test1(1, 'a');
     B::test2(1, 'a');
     self::test3(1, 'a');
     parent::test4(1, 'a');
 }
Example #2
0
<?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);
Example #3
0
<?php

class A
{
    public static $test1 = true;
    public static $test2 = array();
    public static $test3 = "str";
}
class B extends A
{
}
A::$test1 = "x";
A::$test2 = "y";
A::$test3 = "z";
var_dump(A::$test1);
var_dump(A::$test2);
var_dump(A::$test3);
var_dump(B::$test1);
var_dump(B::$test2);
var_dump(B::$test3);
Example #4
0
<?php

class A
{
    public static $name = 'yogi';
    public $add = 'as';
    public static function myTest()
    {
        //$this->name = 'ssa'; //Fatal error: Using $this when not in object context
        return A::$name = 'static variable from static method';
        //return A::$add; //Fatal error: Access to undeclared static property: A::$add
    }
    public function test1()
    {
        return A::$name = 'static variable from non static method.';
    }
}
$a = new A();
//echo $a->myTest(); //Strict Standards: Accessing static property A::$name as non static
echo A::myTest();
echo "<br>";
echo $a->test1();