dougaoshang0237
2015-06-11 15:50
浏览 45
已采纳

php中带有参数问题的构造函数

I'm not able to get the arguments passed onto a function in the constructor. Let me a bit clear with the code snippet below.

class Foo{
    public function __construct($arg){
         $arg = $arg1;
    }

    public function A($arg1){
        echo $arg1;
    }
}

$obj = new Foo();
$data = $obj->A('hello');

Here, the call is being made to the function A with an argument. I'm not able to get the same argument value in the constructor. I'm just giving an idea of my code.

3条回答 默认 最新

相关推荐 更多相似问题