RE: [PHP] something like __URL__ (analogous to __FILE__)

From: Date: Wed, 24 Mar 2004 01:01:01 +0000
Subject: RE: [PHP] something like __URL__ (analogous to __FILE__)
Groups: php.general 
Request: Send a blank email to php-general+get-181341@lists.php.net to get a copy of this message
motorpsychkill <mailto:x@americanmotorcycle.com> on Tuesday, March 23, 2004 4:51 PM said: > So no matter what file I use (like rabbits.php) and I include > config.php, CONFIG_FILE_URL will always return the url for the config > file and NOT the file doing the calling (rabbits.php). hmm... the only thing i can think of is to build it myself. <?php function file_url($file) { $url_base = "http://localhost/"; $server_base = "c:\htdocs\"; return str_replace($server_base, $url_base, $file); } echo file_url(__FILE__); ?> untested but i think you get the picture. chris. p.s. i would define $url_base and $server_base within a constants file that is included somewhere.

« previous php.general (#181341) next »