Possible Duplicate:
Derived class defined later in the same file “does not exist”?
Does anyone has the slighties idea why I’m getting a Fatal Error: Class ‘PublicacionController’ not found when trying to initialize it in the if statement below ?
--PublicacionController.php--
<?php
/*Some random includes, those are
right as far as Im concerned*/
//AJAX call
if(!empty($_POST)){
if($_POST['call']=='nuevaPublicacion'){
$pc = new PublicacionController();
$pc->nuevaPublicacion($_POST);
exit;
}
}
class PublicacionController extends Controller{/* STUFF*/}
?>
It is a single file. Im calling the controller from an AJAX call (dunno if it has something to do with).
I’m running a standard Amazon Ec2 instance, with Amazon Linux and the default https and PHP versions from the repos (the same Fedora uses I think).
PHP classes should be defined before instantiation, see the “new” section of the PHP OO documentation.
An easy way to achieve that is by first declaring the classes and then the main code: