note 72631 added to function.getcwd
| From: | troydotcreggeratgmaildotcom at osu1 dot php dot net | Date: | Fri, 26 Jan 2007 20:10:31 +0000 |
| Subject: | note 72631 added to function.getcwd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122243@lists.php.net to get a copy of this message | ||
Take care if you use getcwd() in file that you'll need to include (using include, require, or
*_once) in a script located outside of the same directory tree.
example:
<?php
//in /var/www/main_document_root/include/MySQL.inc.php
if (strpos(getcwd(),'main_')>0) {
//code to set up main DB connection
}
?>
<?php
//in home/cron_user/maintenance_scripts/some_maintenance_script.php
require_once ('/var/www/main_document_root/include/MySQL.inc.php');
?>
In the above example, the database connection will not be made because the call to getcwd() returns
the path relative to the calling script ( /home/cron_user/maintenance_scripts ) NOT relative to the
file where the getcwd() function is called.
----
Server IP: 64.71.164.2
Probable Submitter: 208.49.239.226
----
Manual Page -- http://www.php.net/manual/en/function.getcwd.php
Edit -- https://master.php.net/note/edit/72631
Del: integrated -- https://master.php.net/note/delete/72631/integrated
Del: useless -- https://master.php.net/note/delete/72631/useless
Del: bad code -- https://master.php.net/note/delete/72631/bad+code
Del: spam -- https://master.php.net/note/delete/72631/spam
Del: non-english -- https://master.php.net/note/delete/72631/non-english
Del: in docs -- https://master.php.net/note/delete/72631/in+docs
Del: other reasons-- https://master.php.net/note/delete/72631
Reject -- https://master.php.net/note/reject/72631
Search -- https://master.php.net/manage/user-notes.php