global variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
StyM
Forum Newbie
Posts: 2
Joined: Mon Dec 15, 2003 8:30 pm

global variable

Post by StyM »

hello and good day.

i have a variable declared inside a php file.
in one of html page, i set the variable some values before going to the next page, when i arrive to my next page the variable is empty. why????

how can i make a variable accessible to any page without lossing its value being set.?????


thanks so much for the help..
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Add the variable within a file and [php_man]include[/php_man]() or [php_man]require[/php_man]() it within all the pages.

Or use cookies, see [php_man]setcookie[/php_man]() in the manual for more information. [php_man]Sessions[/php_man] are also another option.
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

But, if it was in HTML, if he did not add the <?php and ?> it will not be parsed. Just hope he has the <?php echo $the_var ?> or so.

-Nay
Post Reply