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?