globals question ...

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
Avihai
Forum Newbie
Posts: 3
Joined: Wed Aug 22, 2007 7:37 am

globals question ...

Post by Avihai »

Hi all,

I've got me a flash form that send the vars to php using the sendAndLoad.
I am trying to get one of the flash vars into a global variable in php and use it all
over the website, whenever I what and in whatever file I need.

All is working well except the global php.

That is the relevant part in php:

global $title;
$title = $_POST['Title'];

Can anyone help?

Thanks,
A.O
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"global" doesn't mean "accessible across pages." It merely means that it is easily accessible on a single page request. You're thinking of sessions.
Avihai
Forum Newbie
Posts: 3
Joined: Wed Aug 22, 2007 7:37 am

Post by Avihai »

feyd,

Thanks for the quick reply.
Could you please explain a bit more?

Thanks,
A.O
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
Avihai
Forum Newbie
Posts: 3
Joined: Wed Aug 22, 2007 7:37 am

Thanks VladSun - got it :-)

Post by Avihai »

:-)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Global means globally accessible within the current request. That means when a user calls the page about.php, any code you have written that is accessed or built into about.php has access to the global variable. To get values accessible across multiple requests (say on about.php and contact.php) you will either need to use sessions or cookies, both of which can be easily found on a search of the PHP manual.
Post Reply