note 66300 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:30:27 +0000
Subject: note 66300 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127625@lists.php.net to get a copy of this message
Note Submitter: azuretek at gmail dot com ---- If you want to use a prefix for a folder in your project you can do as follows. In my case I wanted to make our dev and prod environments include based on whichever folder we were using as the document root. Though it would be also useful if you want a system to act differently based on which folder it resides in, eg. different results for email, security, and urls. This will return the proper info no matter where the file is as long as it's contained within the document root. You can do it like this: $envPrefix = $_ENV['PWD']; preg_match('/\/.*\/(.*)_project/', $envPrefix, $matches); $envPrefix = $matches[1]; will return: array(2) { [0]=> string(25) "/home/dev_project" [1]=> string(3) "dev" } You can then use that prefix to include the proper files. This method is useful for developers with seperate copies of their project, live and dev. It helps with merging updates, less or nothing to change in between each copy.

« previous php.notes (#127625) next »