开发者

PHP class problems. Can't call another class?

I have a class file: class_xx.php. And then a function file: function_xxx.php

In my function_xxx.php:

require_once('class_xx.php')

... // after few next lines

$object = new class_xx1($arg1, $arg2);

But it gives me:

Fatal error: Class 'class_xx1' not found in "some_path" on line "1XX3"

[sorry I can't exposed the codes yet], any idea why I included the fil开发者_开发百科e > require_once with no error, but it gives me "Class not found error"??


Seemingly, the class_xx.php does not correctly declare the class_xx1 class. Review your code and watch for typos. Put some sort of debug line like echo "hello; in the required file if you want to be sure that it is being included correctly.


Chances are you misspelled the class declaration or something to that avail. You will what to double-check that your spell it the exact same way, with the same casing.

If you are developing on a secondary sever, you might have not transferred the completed class_xxx.php file over and just a blank file, in which case PHP would be including a blank file.

By the way, you forgot a semi-colon after the require_once

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜