TEENFRONT Posted December 11, 2008 Share Posted December 11, 2008 Hi I need to be able to set a few things as "Global site Settings" in php so other php files around the site can refer to them. a simplified overview of how my pages are setup is below.. index.php - includes header.php content here includes ads.php more content here includes footer.php games.php includes header.php content here includes ads.php more content here includes footer.php etc etc i set $LOG_ADS = "YES"; in header.php then use if($LOG_ADS == "YES") { logs ad code here } in my ads.php file.. for some reason, it doesnt see a value for LOG_ADS, like it cannot grab it from header.php I was wondering is there an easy way to set your own site globals in one file, include that in a page then let other included pages use the glabl info? make sense? So index.php is like this. include header.php (this is where $LOG_ADS is) content include ads.php (not picking up the $LOG_ADS value) more content include footer.php Quote Link to comment https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/ Share on other sites More sharing options...
premiso Posted December 11, 2008 Share Posted December 11, 2008 define Will set constants. See above for usage. Quote Link to comment https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/#findComment-712555 Share on other sites More sharing options...
PFMaBiSmAd Posted December 11, 2008 Share Posted December 11, 2008 You would need to post your code showing how you are including the files. Quote Link to comment https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/#findComment-712580 Share on other sites More sharing options...
TEENFRONT Posted December 11, 2008 Author Share Posted December 11, 2008 Great stuff works perfect, thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/#findComment-712585 Share on other sites More sharing options...
TEENFRONT Posted December 11, 2008 Author Share Posted December 11, 2008 actually... it didnt seem to help.. its still not picking up the LOG_ADS value... no real "code" as such... just simple includes... but il lay it out for you.. index.php include('/path/to/file/header.php'); html html html html include('/path/to/file/ads.php'); html html html include('/path/to/file/footer.php'); header.php include('/path/to/file/settings.php'); html html html html settings.php <? define("LOG_ADS", "YES"); ?> ads.php if(LOG_ADS == "YES") { mysql_query } people visit index.php that includes all the files, and the included header file, includes settings file which is where iv used the define. ads.php isnt picking up LOG_ADS value..? cheers! Quote Link to comment https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/#findComment-712602 Share on other sites More sharing options...
premiso Posted December 11, 2008 Share Posted December 11, 2008 It should be, from that it should work exactly as you described. Are there any errors? Try adding this to index.php and see what happens: index.php ini_set("display_errors", 1); error_reporting(E_ALL); include('/path/to/file/header.php'); html html html html include('/path/to/file/ads.php'); html html html include('/path/to/file/footer.php'); Quote Link to comment https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/#findComment-712617 Share on other sites More sharing options...
TEENFRONT Posted December 11, 2008 Author Share Posted December 11, 2008 Hey, thanks for your help. I stuck include('/path/to/file/settings.php'); in ads.php and its working now :S This will do for now lol, its only an extra line in a few files so sorted i guess! Quote Link to comment https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/#findComment-712633 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.