本文整理汇总了PHP中A::test1方法的典型用法代码示例。如果您正苦于以下问题:PHP A::test1方法的具体用法?PHP A::test1怎么用?PHP A::test1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类A
的用法示例。
在下文中一共展示了A::test1方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
function test()
{
A::test1(1, 'a');
B::test2(1, 'a');
self::test3(1, 'a');
parent::test4(1, 'a');
}
示例2: test3
<?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);
示例3: array
<?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);
示例4: myTest
<?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();