note 116619 added to reserved.variables

From: Date: Thu, 29 Jan 2015 21:29:40 +0000
Subject: note 116619 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-201558@lists.php.net to get a copy of this message
So you have an application in your web space, with a URL such as this: http://<host>/<installation_path>/ and pages such as http://<host>/<installation_path>/subfolder1/subfolder2/page.php You have a file called config.php in <installation_path> which is include()d by all pages (in subfolders or not). How to work out <installation_path> without hard-coding it into a config file? http://toronto-personal-injury.lawyer/ <?php // this is config.php, and it is in <installation_path> // it is included by <installation_path>/page.php // it is included by <installation_path>/subfolder/page2.php // etc $_REAL_SCRIPT_DIR = realpath(dirname($_SERVER['SCRIPT_FILENAME'])); // filesystem path of this page's directory (page.php) $_REAL_BASE_DIR = realpath(dirname(__FILE__)); // filesystem path of this file's directory (config.php) $_MY_PATH_PART = substr( $_REAL_SCRIPT_DIR, strlen($_REAL_BASE_DIR)); // just the subfolder part between <installation_path> and the page $INSTALLATION_PATH = $_MY_PATH_PART ? substr( dirname($_SERVER['SCRIPT_NAME']), 0, -strlen($_MY_PATH_PART) ) : dirname($_SERVER['SCRIPT_NAME']) ; // we subtract the subfolder part from the end of <installation_path>, leaving us with just <installation_path> :) ?> ---- Server IP: 72.52.91.14 Probable Submitter: 70.73.20.184 ---- Manual Page -- http://php.net/manual/en/reserved.variables.php Edit -- https://master.php.net/note/edit/116619 Del: integrated -- https://master.php.net/note/delete/116619/integrated Del: useless -- https://master.php.net/note/delete/116619/useless Del: bad code -- https://master.php.net/note/delete/116619/bad+code Del: spam -- https://master.php.net/note/delete/116619/spam Del: non-english -- https://master.php.net/note/delete/116619/non-english Del: in docs -- https://master.php.net/note/delete/116619/in+docs Del: other reasons-- https://master.php.net/note/delete/116619 Reject -- https://master.php.net/note/reject/116619 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201558) next »