本文整理汇总了PHP中Foo::test方法的典型用法代码示例。如果您正苦于以下问题:PHP Foo::test方法的具体用法?PHP Foo::test怎么用?PHP Foo::test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foo
的用法示例。
在下文中一共展示了Foo::test方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
<?php
require __DIR__ . "/classes.php.inc";
class Foo
{
public static function test() : A
{
return new A();
}
}
class Bar extends Foo
{
public static function test() : A
{
return new B();
}
}
var_dump(Bar::test());
var_dump(Foo::test());
示例2: test
<?php
class Foo
{
protected $unsetme = 1;
protected $keepme = 2;
public function test()
{
$a = get_object_vars($this);
foreach ($a as $k => $v) {
if ($k == 'unsetme') {
echo "Unsetting: {$k}\n";
unset($a[$k]);
} else {
if ($k == 'keepme') {
echo "Changing: {$k}\n";
$a[$k] = 42;
$a['keepme'] = 43;
}
}
}
var_dump($a, array_keys($a));
}
}
$f = new Foo();
$f->test();
示例3: test
}
class Simple
{
function test()
{
static $i;
$i++;
return $i;
}
}
test();
test();
Foo::test();
Foo::test();
Bar::test();
Bar::test();
$simple = new Simple();
$simple->test();
$simple->test();
static $one = 20, $two, $three = 40;
if ($one !== 20) {
return 'fail_1';
}
if ($two !== null) {
return 'fail_2';
}
if ($three !== 40) {
return 'fail_3';
}
return test() + Foo::test() + Bar::test() + $simple->test() === 12 ? 'success' : 'fail';
示例4: test4
public static function test4()
{
parent::test();
// Gives Foo, even though we're calling from a child
}
示例5: test
public function test($a)
{
parent::test($a);
}
示例6: define
[expect php]
[file]
<?php
require 'Phalanger.inc';
define('TEN', 10);
class Foo
{
const HUN = 100;
function test($x = Foo::HUN)
{
static $arr2 = array(TEN => 'ten');
static $arr = array(Foo::HUN => 'ten');
__var_dump($arr);
__var_dump($arr2);
__var_dump($x);
}
}
@Foo::test();
echo Foo::HUN . "\n";
示例7: test
<?php
class Foo
{
public static function test()
{
throw new Exception('a');
return 'a';
}
}
try {
$a = Foo::test();
} catch (Exception $e) {
echo 'b';
}
var_dump($a);
示例8: test
--TEST--
Bug #138
--FILE--
<?php
class Foo
{
var $bla = 'fail';
function test()
{
//against dead code optimization (=, call func, return and etc.)
$var = function () {
if (true) {
//or other code blocks (if, switch-case, while, for)
//against dead code optimization
$var = function () {
$this->bla = 'fooo';
};
$var();
}
};
$var();
}
}
$foo = new Foo();
$foo->test();
var_dump($foo->bla);
?>
--EXPECT--
string(4) "fooo"
示例9: __call
<?php
class Foo
{
public function __call($a, $b)
{
print "nonstatic\n";
var_dump($a);
}
public static function __callStatic($a, $b)
{
print "static\n";
var_dump($a);
}
public function test()
{
$this->fOoBaR();
self::foOBAr();
$this::fOOBAr();
}
}
$a = new Foo();
$a->test();
$a::bAr();
foo::BAZ();