scope of the variable in PHP

Discussion in 'PHP' started by shabbir, Apr 4, 2007.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I have been doing quite a bit of PHP but I never tried this and would like to know if this is possible.

    Is there any way I can define the scope of the variable in PHP?

    Lets say I have an if statement and I want the variable to leave only in the if statement and the value should not be outside of the if statement. Is this possible in PHP.
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    PHP doesn't have the range of scopes that C++ has. Generally speaking, you have global scope and function scope. An item at function scope may be declared static.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Yup that does not sound to me very good in PHP. :rolleyes:
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice