Jump to content

Variable Scope Question


Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...