Re: Does this seem wrong to anyone else?

From: Date: Wed, 20 Aug 2008 21:40:59 +0000
Subject: Re: Does this seem wrong to anyone else?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-278428@lists.php.net to get a copy of this message
On 20 Aug 2008, at 22:09, Stephen Johnson wrote:
I am debugging someone else’s code, and this is what they have :
1055    function mkdir_recursive($pathname, $mode)
1056    {
1057        is_dir(dirname($pathname)) ||
mkdir_recursive(dirname($pathname), $mode);
1058        return is_dir($pathname) || @mkdir($pathname, $mode);
1059    }
The part that bothers me is that mkdir_recursive calls itself from within itself. I am not an expert on this particular type of thing, and maybe that is allowed, but it seems wrong to me, and this error is being generated: Fatal error: Call to undefined function mkdir_recursive() in xxxxx.php on line 1057
It's got "recursive" in its name so I'd be surprised if it didn't call itself. As for the error I don't really know since the code you've provided clearly defines that function on line 1055. As someone else has mentioned you might want to make sure that xxxxx.php is the same file that you've posted the snippet from. If you're using PHP5 then you might be interested to know that the mkdir function supports recursive creation. Check http://php.net/mkdir for details. -Stut -- http://stut.net/

« previous php.general (#278428) next »