note 116522 added to function.include
| From: | Rash | Date: | Sat, 17 Jan 2015 17:55:05 +0000 |
| Subject: | note 116522 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201444@lists.php.net to get a copy of this message | ||
If you want to have include files, but do not want them to be accessible directly from the client
side, please, please, for the love of keyboard, do not do this:
<?php
# index.php
define('what', 'ever');
include 'includeFile.php';
# includeFile.php
// check if what is defined and die if not
?>
The reason you should not do this is because there is a better option available. Move the
includeFile(s) out of the document root of your project. So if the document root of your project is
at "/usr/share/nginx/html", keep the include files in "/usr/share/nginx/src".
<?php
# index.php (in document root (/usr/share/nginx/html))
include __DIR__ . '/../src/includeFile.php';
?>
Since user can't type 'your.site/../src/includeFile.php', your includeFile(s) would
not be accessible to the user directly.
----
Server IP: 72.52.91.14
Probable Submitter: 59.161.78.34
----
Manual Page -- http://php.net/manual/en/function.include.php
Edit -- https://master.php.net/note/edit/116522
Del: integrated -- https://master.php.net/note/delete/116522/integrated
Del: useless -- https://master.php.net/note/delete/116522/useless
Del: bad code -- https://master.php.net/note/delete/116522/bad+code
Del: spam -- https://master.php.net/note/delete/116522/spam
Del: non-english -- https://master.php.net/note/delete/116522/non-english
Del: in docs -- https://master.php.net/note/delete/116522/in+docs
Del: other reasons-- https://master.php.net/note/delete/116522
Reject -- https://master.php.net/note/reject/116522
Search -- https://master.php.net/manage/user-notes.php