class sample {
function __call($a, $b) {
echo ucwords(implode(' ', $b).' '.$a);
} function ads() {
ob_start();
echo 'by';
return $this;
}
function ade() {
$c = ob_get_clean();
$this->php('power',$c);
}}
$inst = new sample();
$inst->cmstop('welcome', 'to'); //Welcome To Cmstopinst->ads()->ade(); //Power By Php
function __call($a, $b) {
echo ucwords(implode(' ', $b).' '.$a);
} function ads() {
ob_start();
echo 'by';
return $this;
}
function ade() {
$c = ob_get_clean();
$this->php('power',$c);
}}
$inst = new sample();
$inst->cmstop('welcome', 'to'); //Welcome To Cmstopinst->ads()->ade(); //Power By Php
class test{ const DE = '_';
private $value; public function __call( $funcname, $arguments ){
switch( $funcname ){
case 't':
$this->value = 123;
break;
case 'x':
$this->value = 456;
break;
default :
$this->value = 789;
break;
}
if( method_exists( $this, self::DE . $funcname) ){
call_user_func( array($this, self::DE . $funcname) );
}
else{
echo '"' , $funcname , '"' , ' is not a method!<br/>';
} } private function _t(){
echo $this->value , "<br/>";
} private function _x(){
echo $this->value , "<br/>";
}
}$test = new test();
$test->t();
$test->x();
$test->a();
class sample {
function __call($a, $b) {
// 解释一下
// __call的第一个参数$a, 是不存在的方法的名,在这里就是cmstop
// __call的第二个参数$b, 是调用方法的参数列表, 在这里就是array('welcome', 'to');
// 不要将 $a、$b 和 welcome、to 对应
echo ucwords(implode(' ', $b).' '.$a);
} function ads() {
ob_start();
echo 'by';
return $this;
}
function ade() {
$c = ob_get_clean();
$this->php('power',$c);
}}
$inst = new sample();
$inst->cmstop('welcome', 'to'); //Welcome To Cmstopinst->ads()->ade(); //Power By Php