本文整理匯總了PHP中Base::foo方法的典型用法代碼示例。如果您正苦於以下問題:PHP Base::foo方法的具體用法?PHP Base::foo怎麽用?PHP Base::foo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Base
的用法示例。
在下文中一共展示了Base::foo方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: main
function main(Base $b)
{
$x = $b->foo();
var_dump($x);
}
示例2: foo
<?php
class Base
{
public $aaa = 1;
protected $bbb = 2;
private $ccc = 3;
function foo($obj)
{
var_dump(get_class($obj));
var_dump(get_object_vars($obj));
}
}
class Child extends Base
{
public $ddd = 5;
protected $eee = 6;
private $fff = 4;
}
$base_obj = new Base();
$base_obj->foo($base_obj);
示例3: foo
<?php
class Base
{
public $aaa = 1;
protected $bbb = 2;
private $ccc = 3;
function foo($obj)
{
var_dump(get_class($obj));
var_dump(get_object_vars($obj));
}
}
class Child extends Base
{
public $ddd = 4;
protected $eee = 5;
private $fff = 6;
}
$base_obj = new Base();
$child_obj = new Child();
$base_obj->foo($child_obj);
示例4: main
function main(Base $b)
{
$x = $b->foo();
$x->say();
}
示例5: __callStatic
<?php
class Base
{
public static function __callStatic($method, $args)
{
$klass = get_called_class();
echo "class {$klass}\n";
}
}
class Derived extends Base
{
}
Base::foo();
Derived::foo();