LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 662 users online 225161 members 1337 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Brando Pernando
Statement A) Statement B is true Statement B) Statem...
Mood: Cheeky
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
3 online / 53 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Adding Reply

Adding Reply
Archived Topic: It will not be bumped to the top of the forum.
Topic How do I call upon variables set in a php function?
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
Mediocre Posted at 3:42 pm on Aug. 21, 2008
edit: I needed to give it a global scope. /idiot

I intialize $valcookies as false. However, I then use my checkcookies() function, which, after checking, does:

$valcookies = true;

I tried to call $valcookies in another function after this had happened, and $valcookies was still false.

Replies
mcox05 Posted at 11:28 pm on Aug. 22, 2008
Two big things to remember. <br> 1. PHP and other web based languages are stateless. So if you are setting a variable to false or true then reloading and/or changing pages then the variable's value will be reset. <p> 2. Are you sure that you are correctly using the scope of the variable. <p> EX 1: <br> public class X <br> { <br> //A field who's state will be retained (unless pages are reloaded or changed) <br> $cookVal; <p> public X() <br> { <br> $cookVal = true; <br> } <p> public checkVal() <br> { <br> return ($cookVal); <br> } <br> } <p> Calling checkVal() would return true. <p> EX 2:public class X <br> { <br> public X() <br> { <br> //local variable that will be garbage collected after method call is finished. <br> $cookVal = true; <br> } <p> public checkVal() <br> { <br> return ($cookVal); <br> } <p> } <p> Calling checkVal() would return false. <p> <br> Forgive me if my PHP syntax is off. I haven't coded in it for a while but hopefully these two examples will clarify your problem. If you post your source code I can give you a more direct answer.
allsmiles Posted at 5:12 pm on Aug. 21, 2008
Can you show the source please? Sounds like you're checking if it's set as opposed to its value.
qi Posted at 3:47 pm on Aug. 21, 2008
Do a barrel roll!
hI jAMES Posted at 3:43 pm on Aug. 21, 2008
lol.. thanks for that.
All 4 previous replies displayed.