Reply to Re: When "static" isn't "static"

Your name:

Reply:


Posted by comp.lang.php on 12/05/05 21:21

Wayne wrote:
> On 5 Dec 2005 11:02:31 -0800, "comp.lang.php"
> <phillip.s.powell@gmail.com> wrote:
>
> >I was under the impression that a static variable retains its value
> >throughout a function (or method) recursive memory stack. However, it
> >changes everytime because it apparently loses its set value.
>
> Try it this way:
>
> [PHP]
> function blah($item) {
> static $baseDir = '';
> if (!$baseDir) {
> $baseDir = $item;
> print_r("baseDir = $baseDir\n");
> }

Sorry that had a worse effect, I'm afraid:

[Quote]
baseDir = "/home/me/stuff"
baseDir = "/."
baseDir = "/.."
[/Quote]

That tried to attempt to alter the root directory instead of the given
base directory.

Phil

>
> $dirID = opendir($item);
> while (($fyl = readdir($dirID)) !== false) {
> if (is_dir("$baseDir/$fyl")) blah($item);
> // DO OTHER STUFF IF IT IS A FILE
> }
> }
> [/PHP]

[Back to original 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

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