Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

variable dieing?

Homerun31Homerun31 Posts: 99Member
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?

Comments

  • JonathanJonathan Posts: 2,914Member
    : 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.");

  • ManningManning Posts: 1,621Member
    : : 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...


  • Homerun31Homerun31 Posts: 99Member
    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...
    :
    :
    :

  • skylarskylar Posts: 82Member
    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:

    [code]

    $var = "foo";

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

    myfunc()
    echo $var;


    displays:
    foo

    [/code]


    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.

    [code]

    $var = "foo";

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

    myfunc()
    echo $var;


    displays:
    bar


    [/code]



    (untested but it probably works ;)
    [b][blue]Snoochie Boochies[/blue][/b]

Sign In or Register to comment.