Jesdisciple Posted November 3, 2007 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 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 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
Archived
This topic is now archived and is closed to further replies.