note 24399 deleted from language.variables.scope by aidan

From: Date: Sun, 04 Jul 2004 02:51:40 +0000
Subject: note 24399 deleted from language.variables.scope by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72508@lists.php.net to get a copy of this message
Note Submitter: jpgiot@ifrance.com ---- when you want to access a variable in nested functions, don't forget that each function depend of local scope, not main scope. this don't work $hello = 'hello'; function a() { function b() { global $hello; echo $hello; } b(); } but this works $hello = 'hello'; function a() { global $hello; // here it is function b() { global $hello; echo $hello; } b(); } and don't forget to declare your variable before using them with global inside a function

« previous php.notes (#72508) next »