Ra7or Posted February 25, 2010 Share Posted February 25, 2010 Hi guys, I try to use a global object. require 'libs/smarty/Smarty.class.php'; global $smarty; $smarty = new Smarty; But its dos not work. I cant use the variable in functions. Asked google says that i have to use global $variablename. Or $GLOBALS['varialbe']; inside the function. OK, the problem is its isn't a variable, its a object. All thinks that i have done will not be. The only way that i know is: create the object again inside the function and again and again..... Thats sucks! Anyone know an other way? Ra7or Link to comment https://forums.phpfreaks.com/topic/193355-global-object/ Share on other sites More sharing options...
inspireddesign Posted February 25, 2010 Share Posted February 25, 2010 You can't pass Global vars in a function. Are you trying to instantiate the object from the Smarty.class? If so, you would do it this way: $smarty = new Smarty(); You are missing the opening and closing braces. Link to comment https://forums.phpfreaks.com/topic/193355-global-object/#findComment-1018050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.