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. Quote 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. Quote 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 ? Quote 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/ Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.