note 86620 added to function.exit

From: Date: Sun, 26 Oct 2008 22:11:00 +0000
Subject: note 86620 added to function.exit
Groups: php.notes 
Request: Send a blank email to php-notes+get-145782@lists.php.net to get a copy of this message
To rich dot lovely at klikzltd dot co dot uk: Using a "@" before header() to suppress its error, and relying on the "headers already sent" error seems to me a very bad idea while building any serious website. This is *not* a clean way to prevent a file from being called directly. At least this is not a secure method, as you rely on the presence of an exception sent by the parser at runtime. I recommend using a more common way as defining a constant or assigning a variable with any value, and checking for its presence in the included script, like: in index.php: <?php define ('INDEX', true); ?> in your included file: <?php if (!defined('INDEX')) { die('You cannot call this script directly !'); } ?> BR. Ninj ---- Server IP: 89.31.146.176 Probable Submitter: 90.23.212.230 ---- Manual Page -- http://www.php.net/manual/en/function.exit.php Edit -- https://master.php.net/note/edit/86620 Del: integrated -- https://master.php.net/note/delete/86620/integrated Del: useless -- https://master.php.net/note/delete/86620/useless Del: bad code -- https://master.php.net/note/delete/86620/bad+code Del: spam -- https://master.php.net/note/delete/86620/spam Del: non-english -- https://master.php.net/note/delete/86620/non-english Del: in docs -- https://master.php.net/note/delete/86620/in+docs Del: other reasons-- https://master.php.net/note/delete/86620 Reject -- https://master.php.net/note/reject/86620 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145782) next »