[PHP] help with global not working

2009-05-13 Thread Joey
Hello All,

 

I am running into a problem after I moved a site from a server with PHP4 to
PHP5.

 

As an example I have a variable defined at the top of my code lets say:

$test_mode  = no;

 

Then within the code I check if we are in test mode to bypass certain
functionality like so:

 

function runTransaction() {

 

global $test_mode;

 

do some things;

do some more things;

 

if ($test_mode == yes) {

 

don't do anything;

} else {

Do something;

}

 

 

My problem is that $test_mode NEVER contains the value no.

 

Any ideas appreciated.

 

Joey



Re: [PHP] help with global not working

2009-05-13 Thread Marc Steinert

Maybe your code overwrites the variable anywhere?
You should think about switching to a constant in that case by using

define('TEST_MODE', true);
[...]
if (TEST_MODE) {
[...]
} else {
[...]
}

Greetings from Germany

Marc

Joey wrote:

Hello All,

 


I am running into a problem after I moved a site from a server with PHP4 to
PHP5.

 


As an example I have a variable defined at the top of my code lets say:

$test_mode  = no;

 


Then within the code I check if we are in test mode to bypass certain
functionality like so:

 


function runTransaction() {

 


global $test_mode;

 


do some things;

do some more things;

 


if ($test_mode == yes) {

 


don't do anything;

} else {

Do something;

}

 

 


My problem is that $test_mode NEVER contains the value no.

 


Any ideas appreciated.

 


Joey





--
Synchronize and share your files over the web for free
http://bithub.net/

My Twitter feed
http://twitter.com/MarcSteinert





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php