note 84571 added to function.exit
| From: | rich dot lovely at klikzltd dot co dot uk | Date: | Sat, 19 Jul 2008 13:24:41 +0000 |
| Subject: | note 84571 added to function.exit | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141687@lists.php.net to get a copy of this message | ||
usefull feature:
@header("location: path/to/home/page") and exit();
EG:
We have a "modular" website, with common header and footer files, and different content
modules, eg photos, usually accessed via index.php?p=photos
index.php:
<?php include "head.php";
include $_GET['p'] . ".php"; //Change this - SECURITY!
include "foot.php";
?>
photos.php:
<?php
@header("location: index.php?p=photos") and exit();
//Code to display photos etc
?>
If someone tries to access photos.php, which doesn't produce a full html page by definition,
the header directive sends them to the full version, returns true, and therefore runs the exit()
function.
If they go in normally, the header function should die with the "headers already sent"
error, which is supressed by the @ and returns false, preventing the exit statement from running due
to lazy execution.
----
Server IP: 92.48.74.199
Probable Submitter: 90.210.12.135
----
Manual Page -- http://www.php.net/manual/en/function.exit.php
Edit -- https://master.php.net/note/edit/84571
Del: integrated -- https://master.php.net/note/delete/84571/integrated
Del: useless -- https://master.php.net/note/delete/84571/useless
Del: bad code -- https://master.php.net/note/delete/84571/bad+code
Del: spam -- https://master.php.net/note/delete/84571/spam
Del: non-english -- https://master.php.net/note/delete/84571/non-english
Del: in docs -- https://master.php.net/note/delete/84571/in+docs
Del: other reasons-- https://master.php.net/note/delete/84571
Reject -- https://master.php.net/note/reject/84571
Search -- https://master.php.net/manage/user-notes.php