5

Why does this code sometimes give a No such file or directory warning but other times a No error warning;

<?php

file_put_contents('*bad*', 'hello world');    // Trigger illegal filename.

?>

Usually gives this error warning;

Warning: file_put_contents(*bad*): failed to open stream: No such file
or directory in C:\root\noerror.php on line 3

but if I wait a minute and run it again, sometimes it says this instead;

Warning: file_put_contents(*bad*): failed to open stream: No error in
C:\root\noerror.php on line 3

Any ideas?

I'm using Windows 7, PHP 5.5.11 and nginx 1.4.6. In my php.ini I've got;

error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
report_memleaks = On
track_errors = On
html_errors = On
error_log = php_errors.log

Which I think are just the normal default development error settings except for error_log.

The same thing happens in the log file - sometimes it says No such file or directory other times it says No error;

[11-Jan-2017 12:29:25 Europe/London] PHP Warning:  file_put_contents(*bad*): failed to open stream: No such file or directory in C:\root\noerror.php on line 3
[11-Jan-2017 12:29:26 Europe/London] PHP Warning:  file_put_contents(*bad*): failed to open stream: No error in C:\root\noerror.php on line 3
Nigel Alderton
  • 2,265
  • 2
  • 24
  • 55

1 Answers1

0

Try to give full access to user on the folder where is bad located

  • mouse right click ->properties -Security ->Edit -select Everyone and save
HamzaNig
  • 1,019
  • 1
  • 10
  • 33