note 55819 added to function.include
| From: | JesperJuhl at osu1 dot php dot net | Date: | Sun, 14 Aug 2005 15:14:53 +0000 |
| Subject: | note 55819 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93641@lists.php.net to get a copy of this message | ||
If you want to prevent direct access to some files and only allow them to be used as include files
by other scripts, then an easy way to accomplish that is to check a define in the include file.
Like this.
includefile.php
---
<?php
defined('_VALID_INCLUDE') or die('Direct access not allowed.');
/* rest of file */
?>
script.php
---
<?php
define('_VALID_INCLUDE', TRUE);
include('includefile.php');
/* rest of file */
?>
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55819
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55819&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55819&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55819&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55819&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55819&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55819&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55819&report=yes
Search -- http://master.php.net/manage/user-notes.php