note 25581 added to function.include

From: Date: Sun, 29 Sep 2002 01:51:05 +0000
Subject: note 25581 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-37377@lists.php.net to get a copy of this message
I just wanted to add a quick note about including a file that doesn't exist and then displaying a 404 message. Here's the code I used: <?if(!@include("$page.php")){include("404.php");}?> This is quick, simple and one line that you can slam anywhere. Similar to a previous post, just puts the initial include as the condition of the if, thus saving the need of another variable. If include returns anything, the page will be displayed. I found this interesting :) -- http://www.php.net/manual/en/function.include.php http://master.php.net/manage/user-notes.php?action=edit+25581 http://master.php.net/manage/user-notes.php?action=delete+25581 http://master.php.net/manage/user-notes.php?action=reject+25581

« previous php.notes (#37377) next »