Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.