note 109341 modified in language.functions by danbrown

From: Date: Mon, 16 Jul 2012 15:42:57 +0000
Subject: note 109341 modified in language.functions by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189211@lists.php.net to get a copy of this message
A Variable declared in Outer Function will not be visible in the Inner Function even if you access it using global.

<?php
function outer_function()
{
	$outer_var = 1;

	function inner_function()
	{
		global $outer_var;
		echo $outer_var; // Not Visible :(
	}

}
?> --was-- function outer_function() { $outer_var = 1; function inner_function() { global $outer_var; echo $outer_var; // Not Visible :( } } A Variable declared in Outer Function will not be visible in the Inner Function even if you access it using global. http://php.net/manual/en/language.functions.php

« previous php.notes (#189211) next »