Re: URL Parsing...

From: Date: Sun, 25 Nov 2007 13:18:09 +0000
Subject: Re: URL Parsing...
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-265006@lists.php.net to get a copy of this message
Richard Heyes wrote: >> one of these should give you something to go on: >> >> echo preg_replace('\.cfm$', '-meta.cfm', >> parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)), "\n"; >> echo preg_replace('\.cfm$', '-meta.cfm', >> $_SERVER['PATH_TRANSLATED']), >> "\n"; >> echo preg_replace('\.cfm$', '-meta.cfm', >> $_SERVER['SCRIPT_FILENAME']), >> "\n"; >> >>> Anything would be helpful. :) > > You don't need the overhead of PCRE, though it is the fastest to write, > since it's already above for you... well if you take a string (filename) and wish to change the end of it somone then I don't think str_replace() is the correct function. what's to say a script doesn't exist called 'my.cfm.php'? > > Or parse_url(). basename(__FILE__) will get you the filename. ah yes basename() - I forgot to put use that in the examples, good catch. >

« previous php.general (#265006) next »