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

Posted by Rik on 05/22/06 13:28

Paul Lautman wrote:
>>> 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.
>> You could circumvent this by:
>> if(!function_exists('inner'){
>> //define function
>> }
>>
>> I'm very curious though why one would need such an imho messy
>> function declaration.
>>
>> Grtz,
>
> I don't actually need it. What happened was that I was having trouble
> getting a variable to be global so that I could use a single callback
> function for my usort and have it sort on different "fields" in my
> array. It worked OK in a test setup, but not in the application.
> Turns out that I hadn't realised that in the application, the
> callback function was declared inside another function, whereas in
> the test setup it was at the top level.


Check, while nesting more and more it becomes hard to find errors like that.
I always try to keep "home-made" funstions in a seperate include for that
reason.

Grtz,
--
Rik Wasmus

 

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

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