Forum Moderators: coopster

Message Too Old, No Replies

global var in php

         

scorpion

12:36 am on Dec 8, 2002 (gmt 0)

10+ Year Member



if you write

global var;

if (!(var==1)) {

var = 1;
header("Location: $PHP_SELF");
}

can you assume that var was not 1 the first time around,

Basically I want a simple PHP code that will refresh the page once AND only once and then STOP. Thanks

andreasfriedrich

1:14 am on Dec 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That won´t work. Each time a PHP script is executed all variables are initialized again.

You would need to pass along a parameter in the URI or store the variable in a session.

BTW var should read $var. I´m not sure whether var is a reserved word in PHP. I believe not, I´m probably just confusing JavaScript and PHP here.

Andreas