note 104308 added to function.filetype
| From: | AbhiJain at osu1 dot php dot net | Date: | Wed, 08 Jun 2011 07:01:12 +0000 |
| Subject: | note 104308 added to function.filetype | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180323@lists.php.net to get a copy of this message | ||
Putting @ in front of the filetype() function does not prevent it from raising a warning (Lstat
failed), if E_WARNING is enabled on your error_reporting.
The most common cause of filetype() raising this warning and not showing a filetype() in the output
(it actually returns NULL) is, if you happened to pass just the 'Dir or File Name' and not
the complete "Absolute or Relative Path" to that 'file or Dir'. It may still
read that file and return its filetype as "file" but for Dir's it shows warning and
outputs NULL.
eg:
$pathToFile = '/var/www';
$file = 'test.php';
$dir = 'somedir';
Output for filetype($file) will be returned as 'file' and possibly without any warning,
but for filetype($dir), it will return NULL with the warning "Lstat failed", unless you
pass a complete path to that dir, i.e. filetype($pathToFile.'/'.$dir).
This happened to me and found this solution after a lot of trial and error. Thought, it might help
someone.
----
Server IP: 69.147.83.197
Probable Submitter: 216.113.168.136
----
Manual Page -- http://www.php.net/manual/en/function.filetype.php
Edit -- https://master.php.net/note/edit/104308
Del: integrated -- https://master.php.net/note/delete/104308/integrated
Del: useless -- https://master.php.net/note/delete/104308/useless
Del: bad code -- https://master.php.net/note/delete/104308/bad+code
Del: spam -- https://master.php.net/note/delete/104308/spam
Del: non-english -- https://master.php.net/note/delete/104308/non-english
Del: in docs -- https://master.php.net/note/delete/104308/in+docs
Del: other reasons-- https://master.php.net/note/delete/104308
Reject -- https://master.php.net/note/reject/104308
Search -- https://master.php.net/manage/user-notes.php