日期:2014-05-17 浏览次数:20498 次
<?php
class Person
{
function talk( $sound )
{
echo $sound;
}
function __call( $method , $args )
{
echo 'you call method ' . $method . '<br>';
echo 'and the arguments are <br>';
var_dump( $args );
}
}
$person = new Person();
$person->test( 1 , TRUE );
?><?php
class Person
{
function talk( $sound )
{
echo $sound;
}
function __call( $method , $args )
{
echo 'you call method ' . $method . '<br>';
echo 'and the arguments are <br>';
var_dump( $args );
}
}
$person = new Person();
call_user_func_array( array( $person , 'talk' ) , array( 'hello' ) );
?>class Person
{
function talk( $sound )
{
echo $sound;
}
function __call( $method , $args )
{
echo 'you call method ' . $method . '<br>';
echo 'and the arguments are <br>';
var_dump( $args );
}
}
class PersonProxy
{
private $person;
function __construct()
{
$this->person = new Person();
}
function __call( $method , $args )
{
call_user_func_array( array( $this->person , $method ) , $args );
}
}
$person_proxy = new PersonProxy();
$person_proxy->talk( 'thank you' );