PHP mkdir - Why is this an invalid argument?

I wanted to experiment with creating directories with a name and current time. I know that I can use the php time () function, but it's hard for me to read. Why can not I create a directory with the name 06-11-2014 11:37:04 or so? The php function mkdir gives me an invalid argument when I try to use this format.

php code

<?php
$newdate = date("m-d-Y H:i:s");

mkdir($newdate, 0755, true);

?>
+4
source share
2 answers

Colons per day ruined it. It is best to use this format:

$newdate = date("m-d-Y H_i_s");
+8
source

You have the following:

mkdir($newdate, 077, true);

But it should be:

mkdir($newdate, 0777, true);

But these permissions 777are a security risk. You better use 775or 755instead:

mkdir($newdate, 0755, true);

777 , 100% , , , - . , , , , .

- 777.

EDIT: , . - :

$newdate = date("m-d-Y H:i:s");
mkdir($newdate, 0777, true);

:

$newdate = date("m-d-Y_H-i-s");
mkdir($newdate, 0755, true);

, , : , Mac OS X. (_) .

+3

Source: https://habr.com/ru/post/1544203/


All Articles