[thelist] one-line suppress PHP warnings?

Paul Bennett Paul.Bennett at wcc.govt.nz
Tue Mar 25 17:17:21 CDT 2008


Hmmm, nothing springs to mind immediately.
Is this what you're trying to do?

function getFile($file){
        if(file_exists($file)){
                include($file);
        }
}

File_exists won't write to the error log if the file isn't found - it'll just return false. The function above will include the file if it's present and will ignore if it isn't.
( You could also look at file_get_contents(). http://nz.php.net/manual/en/function.file-get-contents.php )

This could (technically) be one line of code...

function getFile($file){ if(file_exists($file)){ include($file);}}
;)

Am I on the right track?

Paul



More information about the thelist mailing list