note 106293 added to function.getenv

From: Date: Tue, 25 Oct 2011 23:25:31 +0000
Subject: note 106293 added to function.getenv
Groups: php.notes 
Request: Send a blank email to php-notes+get-184125@lists.php.net to get a copy of this message
For CLI & Web I use: <?php $docRoot = (PHP_SAPI == 'cli') ? substr((dirname(__FILE__).'/'), 0, strpos((dirname(__FILE__).'/'), '/','14')) : getenv("DOCUMENT_ROOT"); ?> It works fairly well - most of my linux servers have home directories that look like this: /home/username/public_html so counting the home directory and slashes is 6 chars + 8 letter username = 14. I add the extra trailing slash for files that happen to be in the root directory all ready. ---- Server IP: 69.147.83.197 Probable Submitter: 173.167.230.23 ---- Manual Page -- http://www.php.net/manual/en/function.getenv.php Edit -- https://master.php.net/note/edit/106293 Del: integrated -- https://master.php.net/note/delete/106293/integrated Del: useless -- https://master.php.net/note/delete/106293/useless Del: bad code -- https://master.php.net/note/delete/106293/bad+code Del: spam -- https://master.php.net/note/delete/106293/spam Del: non-english -- https://master.php.net/note/delete/106293/non-english Del: in docs -- https://master.php.net/note/delete/106293/in+docs Del: other reasons-- https://master.php.net/note/delete/106293 Reject -- https://master.php.net/note/reject/106293 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184125) next »