|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-05-22 07:10 UTC] golden dot pr at mail dot ru
Description: ------------ --- From manual page: http://www.php.net/function.filemtime --- filemtime() must return false if file not exist Test script: --------------- $path = './test.txt'; echo @filemtime($path); Expected result: ---------------- filemtime(): stat failed for {$path} Actual result: -------------- false PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Expected result: ---------------- false Actual result: -------------- filemtime(): stat failed for {$path}it does exactly what the docs say, the only thing which should be fixed is the braindead warning for functions which return false in case of errors so that you don't need @ or a uselss file_exists() around the code you likely miss one of the most important facts when working with PHP: ===, !== when compare values and when boolean false is converted to a string it's an empty string, since echo is working with string it does implicit typecasting and false is something completly different then the string 'false' php > echo false; php > php > if(filemtime('nonexists') === false){echo 'NON-EXISTS';} Warning: filemtime(): stat failed for nonexists in php shell code on line 1 NON-EXISTS