Jump to content

Variable Scope Question


Jesdisciple

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...