Why with Php5.2
$asr =& new AjaxSearchResults(); //! model
$aso =& new AjaxSearchOutput(); //! ouput view
$asi =& new AjaxSearchInput(); //! input
$asc =& new AjaxSearchCtrl(); //! controller
$asc->run();
$output = $asc->output;
i can’t retrieve the global variables $asi, $asc, $aso inside classes.
For instance inside AjaxSearchCtrl
class AjaxSearchCtrl{
var $output;
var $ok;
var $msgerr;
function AjaxSearchCtrl() {
}
function run(){
global $modx;
global $asi; //! input view
global $aso; //! output view
// input form display
if(!is_object($asi)){echo"<font color=’red’ size=’5’>asi is not an object</font>";}
$asi->display();
if ($asi->ok) {
$this->listenEvents();
}
else $this->output = $asi->msgerr;
}
function listenEvents(){
global $modx;
global $asi; //! input view
global $aso; //! output view
//! call the appropriate logic depending the events and context
$aso->display();
$this->output = $aso->output;
}
}
And why I need to use $GLOBALS to retrieve the content of global variables:
$GLOBALS[’asr’] =& new AjaxSearchResults(); //! model
$GLOBALS[’aso’] =& new AjaxSearchOutput(); //! ouput view
$GLOBALS[’asi’] =& new AjaxSearchInput(); //! input
$GLOBALS[’asc’] =& new AjaxSearchCtrl(); //! controller
$GLOBALS[’asc’]->run();
$output = $GLOBALS[’asc’]->output;
Is it due to the version of PHP or a correct behaviour ?