PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
variable dieing? Posted by Homerun31 on 27 Jul 2004 at 1:35 PM
dunno no why but ive been using this same variable for a long time and it has been working fine and then out of no where it wasnt working. any reason why that would happen?
Report
Re: variable dieing? Posted by Jonathan on 27 Jul 2004 at 2:21 PM
: dunno no why but ive been using this same variable for a long time and it has been working fine and then out of no where it wasnt working. any reason why that would happen?
:
Sounds odd, can you post some example code that shows this happening? Are you sure it isn't a scoping issue?

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Report
Re: variable dieing? Posted by Manning on 27 Jul 2004 at 7:45 PM
: : dunno no why but ive been using this same variable for a long time and it has been working fine and then out of no where it wasnt working. any reason why that would happen?
: :
: Sounds odd, can you post some example code that shows this happening? Are you sure it isn't a scoping issue?


Just a guess, but maybe it's a global variable from a get/post/cookie/etc that worked with the old PHP versions, but his provider upgraded and now register_globals is off so the variable is now invalid.

homerun31: If that sounds possible, try changing from this syntax: $foobar, to this: $_GET['foobar'] or $_POST['foobar'] or $_COOKIE['foobar'] or etc...


Report
Re: variable dieing? Posted by Homerun31 on 27 Jul 2004 at 8:14 PM
whats scoping mean?



: : : dunno no why but ive been using this same variable for a long time and it has been working fine and then out of no where it wasnt working. any reason why that would happen?
: : :
: : Sounds odd, can you post some example code that shows this happening? Are you sure it isn't a scoping issue?
:
:
: Just a guess, but maybe it's a global variable from a get/post/cookie/etc that worked with the old PHP versions, but his provider upgraded and now register_globals is off so the variable is now invalid.
:
: homerun31: If that sounds possible, try changing from this syntax: $foobar, to this: $_GET['foobar'] or $_POST['foobar'] or $_COOKIE['foobar'] or etc...
:
:
:

Report
Re: variable dieing? Posted by skylar on 9 Aug 2004 at 9:24 AM
scope refers to where a variable resides.

there is GLOBAL scope meaning available to the entire script..
scope within functions (only functions have access to it)

(im unsure about the rest.. too tired to research lol)

You can have a variable outside of a function and have one WITHIN a function having the SAME name WITHOUT them having anything to do with one another:


$var = "foo";

function myfunc(){
 $var = "bar";
}

myfunc()
echo $var;


displays:
foo




though if you declare a variable as being of GLOBAL scope within a function, it treats it as if it were part of the entire script.


$var = "foo";

function myfunc(){
 global $var;
 $var = "bar";
}

myfunc()
echo $var;


displays:
bar






(untested but it probably works ;)
Snoochie Boochies




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.