ZF-3249: Use of fopen with '@' triggers error-handler

Issue Type: Bug Created: 2008-05-13T03:40:20.000+0000 Last Updated: 2012-03-26T08:43:50.000+0000 Status: Resolved Fix version(s): - 1.5.2 (15/May/08)

Reporter: wego (wego72) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Loader

Related issues: - ZF-2985



The method Zend_Loader::isReadable() uses fopen to check if a file exists and the @-operator to abort its error-messages:

<pre class="highlight">
public static function isReadable($filename)
    if (!$fh = @fopen($filename, 'r', true)) {
        return false;

    return true;

This only aborts the messages from beeing displayed, the error-handler will be triggert anyway. So if you use your own error-handler, everytime a file is beeing checked with this function and not found (and this may happen very often) a php-notice is thrown and beeing logged into your logfile for example or your database.

Why not use the 'file_exists()' function of php?

// example with include path:

<pre class="highlight">
static $paths = null;
if ($paths == null) {
    $paths = explode(PATH_SEPARATOR, get_include_path());
foreach ($paths as $path) {
    $fullpath = $path.DIRECTORY_SEPARATOR.$filename;
    if (file_exists($fullpath)) {
        return true;
return file_exists($filename);


Posted by James Dempster (letssurf) on 2008-05-13T05:34:53.000+0000

I think it's cause file_exits() doesn't follow the include path where as the third parameter of fopen() is weather is should use the include path or not.

Posted by julien PAULI (doctorrock83) on 2008-05-13T08:20:49.000+0000

Hum, just use in you error handler function :

if(error_reporting() == 0) { return; }

When the error handler catches the error, the @ puts silently error_reporting level to 0, so you can detect errors comming from 'arobased' instructions.

Posted by old of Satoru Yoshida ( on 2008-05-14T04:43:34.000+0000

I think it duplicates with ZF-2985

Posted by Wil Sinclair (wil) on 2008-12-17T12:38:53.000+0000

Bookkeeping. We're trying to assign all resolved issues to the people who resolved them.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.