I’m getting this really bad error. I tried copying the example classes off PHP.net. The class worked but I cant seem to get it to include right. My index file includes the users.class.php and then the content.php which has the call to the class.
Error:
Fatal error: Class ‘A’ not found in
X:\xxxxx\xxxx\xxxxx\content.php on
line 2
index.php:
<?php
require('users.class.php');
$a = new A();
require('content.php');
?>
content.php:
<?php
echo $a->foo();
?>
users.class.php:
<?php
class A
{
function foo()
{
return 'hello world';
}
}
?>
hmm… my guess is that the line
is being executed before the preprocessor has fully read in users.class.php.
try adding this line to content.php:
above the
echo...line.Also, change your index.php
requiretorequire_onceas well. This will ensure that your class is read in before code is executed, and you won’t get any errors saying that the file has already been included.