Jump to content

[SOLVED] Setting your own "Globals"


TEENFRONT

Recommended Posts

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

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/136513-solved-setting-your-own-globals/
Share on other sites

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!

 

 

 

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');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.