ShaKeD Posted May 9, 2007 Share Posted May 9, 2007 Hey, I`v a problem. I`m using include function. include 'lang.php'; now I want to use all of the variables that exist in lang.php .. the problem is that I`m using functions on my index.php file, and I don't want to enter the function every time with those variables. how can I fix it? 10x. Link to comment https://forums.phpfreaks.com/topic/50703-hey-again-this-time-i-need-help-function-with-global-vars/ Share on other sites More sharing options...
per1os Posted May 9, 2007 Share Posted May 9, 2007 Make the variables in the lang.php constants. IE: //lang.php <?php // insetad of $my_welcome_text = "Welcome Home!"; //use define('MY_WELCOME_TEXT', 'Welcome Home!'); ?> That way it is available to every function, class etc as long as it is included. Link to comment https://forums.phpfreaks.com/topic/50703-hey-again-this-time-i-need-help-function-with-global-vars/#findComment-249252 Share on other sites More sharing options...
ShaKeD Posted May 9, 2007 Author Share Posted May 9, 2007 ok, thanks but maybe there is a way to "define" the include ? Link to comment https://forums.phpfreaks.com/topic/50703-hey-again-this-time-i-need-help-function-with-global-vars/#findComment-249255 Share on other sites More sharing options...
mendoz Posted May 9, 2007 Share Posted May 9, 2007 You might find these helpful: http://www.php.net/global http://www.phpit.net/article/using-globals-php/ Link to comment https://forums.phpfreaks.com/topic/50703-hey-again-this-time-i-need-help-function-with-global-vars/#findComment-249263 Share on other sites More sharing options...
ShaKeD Posted May 9, 2007 Author Share Posted May 9, 2007 I used $lang as array lang.php - $lang[blah] = ' blah ' ; $lang[blaas] = ' blah sadf'; index.php - include 'lang.php'; $_GLOBALS['lang'] = $lang; but when I`m using $lang inside my functions it doesn't work. Link to comment https://forums.phpfreaks.com/topic/50703-hey-again-this-time-i-need-help-function-with-global-vars/#findComment-249289 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.