On Friday 29 December 2006 2:00 pm, Dan Cech wrote: > Yes, If you want the full filename (including filesystem path) __FILE__ > is indispensable, and basename(__FILE__) is the best way to get the name > of the currently running script. > > The problem comes when you're attempting to construct the correct > absolute URL for a given file. When running php as a cgi there doesn't > seem to be a method of achieving this securely, as in this setup > $_SERVER['SCRIPT_NAME'] will contain the php interpreter, like > '/php-cgi'. > > Bottom line is that if your script will be run under php-cgi you must > not use SCRIPT_NAME, so we're back to square one.
There's a solution for that (two solutions in fact, either a php.ini setting or a different variable): http://www.symfony-project.com/trac/ticket/842 So I suppose the canonical solution would be something like: $thispage = (isset($_SERVER['ORIG_SCRIPT_NAME'])) ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']; How's that? That should work anywhere, right? (Disclaimer: I never use PHP as a cgi script and can't test this.) Michael Sims _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
