Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在类 ceff() 中有一个名为 wsGO() 的函数。我希望能够从 ceff 类中运行该函数。我使用了这段代码:
class ceff{ $ceff_instance = new ceff($this); $ceff_instance = wsGO(); public function wsGO(){ .... } }
然而这并没有奏效。有任何想法吗?
在 PHP 中,您只能使用常量初始化属性 - 而不是函数或构造函数调用。您可以在构造函数中执行此操作,例如:
class ceff{ public $ceff_instance; public function __construct() { $this->ceff_instance = $this->wsGO(); } public function wsGO(){ .... } }