LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 656 users online 221611 members 1602 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
PROgoth121
Peeves: I get really pissed off when people ta...
Mood: Angry
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
6 online / 32 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 | Days Active: 209
Join to learn more about Mediocre Czech Republic | Male | Posts: 1,642 | Points: 3,195
LiveWire Humor
jamesish


Hagel und tötet

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

3:43 pm on Aug. 21, 2008 | Joined: Jan. 2008 | Days Active: 528
Join to learn more about jamesish South Carolina, United States | Bisexual Male | Posts: 23,946 | Points: 38,443
qi


Visionary

Patron
Reply
Do a barrel roll!

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


Enlightened One

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 | Days Active: 564
Join to learn more about allsmiles England, United Kingdom | Male | Posts: 8,800 | Points: 15,765
mcox05


Grasshopper
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 | Days Active: 3
Join to learn more about mcox05 United States | Posts: 14 | Points: 44
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