I’ve been getting this error on my MediaWiki installation, but I’m not sure it’s too localized to MediaWiki.
When including (or requiring, or using other methods) a file in a PHP script, I’m getting this:
class aClass() { } //Contents of file
Fatal error: Class 'aClass' not found in /path/path/file.php on line 9
aClass is just a test, and as you can see, it’s not being loaded.
aClass is defined in the file I’m including. (This file is the one being echoed.) This file contains just the class aClass() { } statement, nothing else.
This is the file that does the requiring:
$dir = dirname(__FILE__) . '/';
$wgAutoloadClasses['RatingData'] = $dir . 'RatingDataClass.php';
//MediaWiki class-loading statement
include $dir . 'RatingDataClass.php';
//simple include still fails
new aClass();
Without the new aClass();, the page loads fine, no errors or anythin abnormal echoed.
There’s nothing in your class file to tell PHP that it’s to be processed, so it’s being treated as HTML; try wrapping it in
<?phptags: