I've got the following piece of code on a PHP 5.2.4 (no safe_mode) linux server:

mkdir( $path, 0777, true );

when I enter a path like:


all directories are created axcept for the last one... when I add another directory like:


again, all paths are created except for the last one...

have tried both with and without trailing slashes

Can any1 enlighten me here please?


Please post the exact version of PHP you're using. Also, is your host running with safe_mode enabled?

Written by Ian Kemp

What's your error_reporting level? If something goes wrong an E_WARNING is raised. safe mode is off, but does your php version contain something like suhosin? How (and from where) did you install php? Compiled from "vanilla" php.net sources? Through your distribution's package manger (which one is it and what's the exact name of the package)? The function php_plain_files_mkdir() (responsible for the php function mkdir(x,y,true)) hasn't changed quite a while and I haven't found a related bug at bugs.php.net

Written by VolkerK

Accepted Answer

Ok the solutions is as follows: there was no problem.

I did not test the code in isolation, but only assumed the following code was not doing anything to the directory structure...

as I found out the directory got deleted later on by the code itself.

Anyway, Lesson learned...

Written by Nicky De Maeyer
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki