note 90527 added to function.include
| From: | Anonymous at osu1 dot php dot net | Date: | Sun, 26 Apr 2009 21:59:16 +0000 |
| Subject: | note 90527 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153790@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 92.48.74.199
Probable Submitter: 84.43.33.165
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- https://master.php.net/note/edit/90527
Del: integrated -- https://master.php.net/note/delete/90527/integrated
Del: useless -- https://master.php.net/note/delete/90527/useless
Del: bad code -- https://master.php.net/note/delete/90527/bad+code
Del: spam -- https://master.php.net/note/delete/90527/spam
Del: non-english -- https://master.php.net/note/delete/90527/non-english
Del: in docs -- https://master.php.net/note/delete/90527/in+docs
Del: other reasons-- https://master.php.net/note/delete/90527
Reject -- https://master.php.net/note/reject/90527
Search -- https://master.php.net/manage/user-notes.php