<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class a{ public $table = ''; public function __contruct($table) { $this->table=$table; }}class b{ $b = new a('abc');//Fatal error: Class 'a' not found}
------解决方案-------------------- 取个例子,更好说明一些. 假设 class a 的代码存在 class_a.php class b 的代码存在class_b.php 上.
PHP code
<?php function __autoload($class_name) { require("class_".$class_name.".php");}$b = new b(); //这样会自动去 加载 class_b.php 文件$a = new a(); //这样会自动去 加载 class_a.php 文件?><div class="clear">
</div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn