note 90527 deleted from function.include by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 08:04:28 +0000 |
| Subject: | note 90527 deleted from function.include by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196795@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Alot of people here in this section in the user contributed notes suggest using
<?php
@include('file.php');
?>
to suppress warnings. This is not a good idea as it will also turn off error reporting in the
included file. If you want to turn off warnings should the include fail use one of the following.
<?php
$theme= "themefoldername";
//turn off warnings
error_reporting(E_ALL & ~E_WARNING);
if(!include('themes/'.$theme.'/index.php'))
{
// file was missing so include default theme
require('themes/default_theme/index.php');
}
// Turn on warnings
error_reporting(E_ALL);
?>
Or maybe this works better
<?php
if(file_exsists('themes/'.$theme.'/index.php'))
include('themes/'.$theme.'/index.php');
else
require('themes/default_theme/index.php');
?>
You decide.