[support] module execution context? was: class and globals in functions (maybe PHP)
    Ivan Sergio Borgonovo 
    mail at webthatworks.it
       
    Tue Oct  2 17:10:49 UTC 2007
    
    
  
I simplified as much as I could and I came out with:
<?
class tonno {
        protected $pippo=null;
        function __construct($pippo) {
                $this->pippo=$pippo;
        }
        public function test() {
                print($this->pippo);
        }
}
$zoppas=new tonno("morto");
function cane() {
        global $zoppas;
        $zoppas->test();
}
cane();
?>
That works perfectly as a separated app in drupal environment (that
means same server, same php.ini, same dir where drupal reside).
then I moved the same code inside my catalog.module but I put the
        global $zoppas;
        $zoppas->test();
in a hook and again:
Fatal error: Call to a member function test() on a non-object
in /srv/twww.mebsbooks.com/d1/sites/all/modules/catalog/catalog.module
on line 63
what's different in the module execution context?
why
global $user;
works?
-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it
    
    
More information about the support
mailing list