<?php
class helloWorld{
function display($count){
for($i=0;$i<$count;$i++){
print "Hello world!\n";
}
return $count;
}
}class HelloWorldDelegator{
private $obj;
function __construct(){
$this->obj = new helloWorld();
}
function __call($method,$args){
return call_user_func_array(array($this->obj,$method),$args);
}
}$obj = new HelloWorldDelegator();
$obj->display(4);
?>理想的输出结果应该是:
Hello World!
Hello World!
Hello World!
Hello World!
4现在的情况是:
只输出了前面的四个Hello World!,而没有输出4.
是代码的错误么?检查了下没有发现错误。来个眼尖的,帮我瞅瞅。。
class helloWorld{
function display($count){
for($i=0;$i<$count;$i++){
print "Hello world!\n";
}
return $count;
}
}class HelloWorldDelegator{
private $obj;
function __construct(){
$this->obj = new helloWorld();
}
function __call($method,$args){
return call_user_func_array(array($this->obj,$method),$args);
}
}$obj = new HelloWorldDelegator();
$obj->display(4);
?>理想的输出结果应该是:
Hello World!
Hello World!
Hello World!
Hello World!
4现在的情况是:
只输出了前面的四个Hello World!,而没有输出4.
是代码的错误么?检查了下没有发现错误。来个眼尖的,帮我瞅瞅。。
$obj = new HelloWorldDelegator();
print ($obj->display(4));哈哈哈哈...
print ($obj->display(4));这年头 我发的怎么不见了...我也来浑水摸鱼
sorry,结贴了才看到你的回复。。要不我再开个帖子?