LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 309 users online 192219 members 345 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Dictionary | News | FAQ
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
2 online / 37 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

How do I call upon variables set in a php function?
Replies: 4Last Post Aug. 22, 2008 11:28pm by mcox05
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( Mediocre )


Dairy Product Addict
Reply
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.

Post edited at 4:50 pm on Aug. 21, 2008 by Mediocre

-------
Incest and bestiality are neat.


3:42 pm on Aug. 21, 2008 | Joined Nov. 2007 | 193 Days Active
Join to learn more about Mediocre Czech Republic | Male | 1642 Posts | 2965 Points
jamesish


Swami

Sustainer
Support Leader
Tech Support Leader
Reply
lol.. thanks for that.

-------
|Myspace|

3:43 pm on Aug. 21, 2008 | Joined Jan. 2008 | 259 Days Active
Join to learn more about jamesish South Carolina, United States | Metrosexual Male | 16659 Posts | 25770 Points
qi


Connoisseur

Patron
Reply
Do a barrel roll!

-------
MY NUDE PICTURES

3:47 pm on Aug. 21, 2008 | Joined April 2008 | 139 Days Active
Join to learn more about qi California, United States | Straight Male | 2613 Posts | 6727 Points
allsmiles


Soothsayer

Patron
Reply
Can you show the source please? Sounds like you're checking if it's set as opposed to its value.

-------
When they leave me, they're all smiles.
When they leave you, they're in tears.

5:12 pm on Aug. 21, 2008 | Joined Aug. 2007 | 391 Days Active
Join to learn more about allsmiles England, United Kingdom | Male | 6747 Posts | 11671 Points
mcox05


Novice
Reply
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.

11:28 pm on Aug. 22, 2008 | Joined Aug. 2008 | 1 Days Active
Join to learn more about mcox05 United States | 1 Posts | 11 Points
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic