Can I execute some methods without inheriting a class? PHPcodeclassa {public $ table = ''; publicfunction _ contruct ($ table) {$ this-& gt; table = $ can I execute some methods when I do not inherit a class?
PHP code
class a{ public $table = ''; public function __contruct($table) { $this->table=$table; }}class b{ $b = new a('abc');//Fatal error: Class 'a' not found}
Can I use another method instead? I want to complete class a constructor initialization in Class B.
------ Solution --------------------
Require_once 'class _ a_file.php ';
------ Solution --------------------
The above is true. the error is not new, but the code of class a is not added.
I often create a new one in one class.
------ Solution --------------------
Discussion
I always thought that this loading should allow PHP to be completed internally. I did not expect it.
------ Solution --------------------
Take an example to better illustrate this.
Assume that the code of class a exists in class_a.php class B.
PHP code