Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   scope of the variable in PHP (http://www.go4expert.com/forums/scope-variable-php-t3750/)

shabbir 4Apr2007 19:44

scope of the variable in PHP
 
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.

DaWei 30Apr2007 20:46

Re: scope of the variable in PHP
 
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.

shabbir 1May2007 09:06

Re: scope of the variable in PHP
 
Quote:

Originally Posted by DaWei
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.

Yup that does not sound to me very good in PHP. :rolleyes:


All times are GMT +5.5. The time now is 08:00.