You are here: Re: Variable scope - function in function « PHP Programming Language « IT news, forums, messages
Re: Variable scope - function in function

Posted by Chung Leong on 05/21/06 22:07

Paul Lautman wrote:
> Here's something that I can't manage to find explicitly documented. In the
> following snippet:
>
> function outer() {
> global $a;
> function inner() {
> global $a;
> echo $a.'1<br>';
> }
> $a = 's';
> inner();
> echo $a.'2<br>';
>
> }
> outer();
> ?>
>
> If either of the globals statements is removed, the variable is not
> accessable within inner.

What you're trying to do won't work if you call outer() more than once.
PHP has no support for closure or inner functions.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация