Jesdisciple Posted November 3, 2007 Report Share Posted November 3, 2007 I have a question, and I suppose it will be easiest to give a model: function foo(){ $var1 = true; if($var1){ $var2 = 0; } echo $var2;//Does this work?} Is $var2 accessible outside of the if block, as $var1 is? If it is, there's no need to declare function variables in the format $name;, but if it's not, this might be a good idea sometimes.EDIT: Never mind; the answer is yes. Sorry for the (second) unnecessary thread. Link to comment Share on other sites More sharing options...
zppblood Posted November 3, 2007 Report Share Posted November 3, 2007 Take a look at the PHP manual at php.net (the official site for PHP).Here is a section on variable scopehttp://us3.php.net/manual/en/language.variables.scope.php Link to comment Share on other sites More sharing options...
Jesdisciple Posted November 5, 2007 Author Report Share Posted November 5, 2007 As far as I can tell, it doesn't address code blocks apart from the global issue. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now