Re: Nested functions

From: Date: Sun, 10 Feb 2002 09:57:16 +0000
Subject: Re: Nested functions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-84157@lists.php.net to get a copy of this message
Thanks for the confirmations Torben. > > Can one code user-defined functions nested within one another > Yes. > > - and repeatedly execute them? > No. ;) > > This is correct. As you know, the thing is that execution keeps running > into that function declaration every time the containing function is > run, tries to declare the function, and fails. Essentially: while you > *can* do nested functions in PHP, don't. :) There really isn't any good > reason to, anyway--except for (perhaps) a wee bit of namespace > clarification. Namespace clarification is exactly what I had in mind - I am post-processing the n=0, 1, >1 results from a preg_match_all() and figured that array_walk() would be faster than for{$i...} or foreach(). However learning that array_walk() demanded use of a function, that implied that my 'modular' function would have to call a (short) second to suit the command structure - thus the logic that nesting would 'keep things together' in reuse/restructure situations. [As you will appreciate, the "test bed" code was almost directly out of the manual, and was only being used so that I could experiment/get my head around the command/and thereafter test the efficiency criteria] I thought I would ask, if only because other languages, even interpreted languages, do cope with this situation - but as you say, it is not a show-stopper - a possible case for FUNCTION_once name() as per REQUIRE and INCLUDE? Thanks again, =dn

« previous php.general (#84157) next »