jjzjj

TheNameOfSomething

全部标签

函数中的 PHP 类参数

我在该类的一个函数中使用我的类的参数时遇到问题。我有一个类叫做公司:classcompany{var$name;function__construct($name){echo$name;}functionname(){echo$name;}}$comp=newcompany('TheNameOfSomething');$comp->name();当我实例化它时(倒数第二行),构造魔术方法工作正常,并回显“TheNameOfSomething”。但是,当我调用name()函数时,我什么也没得到。我做错了什么?任何帮助是极大的赞赏。如果您需要任何其他信息,请询问!谢谢-吉尔斯http://