note 86881 added to function.getcwd
| From: | BigueNique at yahoo dot ca | Date: | Fri, 07 Nov 2008 17:59:32 +0000 |
| Subject: | note 86881 added to function.getcwd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146294@lists.php.net to get a copy of this message | ||
Hey folks, here are a few tips.
First, realpath() doesn't work in safe mode, so don't rely on it if you plan to deploy
your site on a webfarm.
Second, the quickest most reliable way to get the directory in which a script resides is to use
"dirname(__FILE__)", so if you want to include, let's say /var/www/mysite/A.php from
/var/www/mysite/B.php, no matter from which directory B.php was invoked:
<?php
include dirname(__FILE__) . "/B.php";
?>
Be careful when using $_SERVER values, as they might not be available on all platforms. I strongly
suggest dumping the $_SERVER superglobal on different PHP setups you wish to support (Apache on
Linux/Windows, IIS, etc...) before deciding to use them.
Also keep in mind that $_SERVER keys starting with 'HTTP_' have been sent by the client
(these are the request's HTTP headers), so their values are 1. not 100% reliable and 2. could
be tweaked by an evilish user trying to break your site security.
----
Server IP: 216.235.15.211
Probable Submitter: 216.239.77.61
----
Manual Page -- http://www.php.net/manual/en/function.getcwd.php
Edit -- https://master.php.net/note/edit/86881
Del: integrated -- https://master.php.net/note/delete/86881/integrated
Del: useless -- https://master.php.net/note/delete/86881/useless
Del: bad code -- https://master.php.net/note/delete/86881/bad+code
Del: spam -- https://master.php.net/note/delete/86881/spam
Del: non-english -- https://master.php.net/note/delete/86881/non-english
Del: in docs -- https://master.php.net/note/delete/86881/in+docs
Del: other reasons-- https://master.php.net/note/delete/86881
Reject -- https://master.php.net/note/reject/86881
Search -- https://master.php.net/manage/user-notes.php