hecate hecate - 1 month ago 8
PHP Question

php - fopen(src_new/temp@2016-10-27_06:45:54.php): failed to open stream: Invalid argument

$filename="temp";
$file="src_new/".$filename."@".date("Y-m-d_H:i:s",strtotime("now + 3 hours + 45 minutes")).".php";
$writeHandle=fopen($file,"w"); // Error is thrown here


I don't understand why it fails to open a file of filename name "temp" appended with the current date and time. Can anyone here please enlighten me on this ?

Note: I have tried escaped backslashes i.e '\' too in the file path but the result no different from the current one.

Answer

MS Windows doesn't "love" colons.

Recommend rename files to: Y-m-d_H.i.s

It works fine for all platforms and filesystems.