Re: nested functions
| From: | Christian Reiniger | Date: | Wed, 16 May 2001 12:50:28 +0000 |
| Subject: | Re: nested functions | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-53024@lists.php.net to get a copy of this message | ||
On Wednesday 16 May 2001 12:12, Hannes Schmiderer wrote:
> elias wrote:
> > good question...I might need an answer when you get one.
>
> Why?
> Ok, I have a perl-counter script which is included to shtml-pages with
> SSI. Now I want to add some PHP pages to my site. So I need a
> PHP-function that does the same as the perl-script does. In the script
> I have a lot of global variables and some auxiliary functions. In PHP
> these variables became local variables of the counter() function and
> the auxiliary functions became nested functions. The auxiliary nested
> functions have to have access to a lot of variables from the counter()
> function, and they even have to change them. I already added all the
> variables (some with call by reference) but I think it would have been
> easier if I had access the counter()-variables within the nested
> auxiliary functions direct.
What about using classes instead of outer functions? Classes provide
rather nice (nestable) scoping.
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
"Software is like sex: the best is for free" -- Linus Torvalds