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.
PHP - 如果我们在 php 中创建子类的对象,它会调用父类构造函数,然后像 java 那样调用类构造函数吗?
不,您需要在子类中调用父构造函数。
public function __construct() { parent::__construct(); //...other code }