From: "John Schulz" <[EMAIL PROTECTED]> > After reading the manual entry on $_SERVER predefined variables, I'm > unclear on the difference between 'SCRIPT_FILENAME' and 'PATH_TRANSLATED'. > > Results from a test script, run from a few different locations on my > webserver, were always the same for these two variables. > > I'm especially confused by the "Filesystem- (not document root-) based > path" comment for 'PATH_TRANSLATED'.
Not sure what to say on this one other than, yeah, they're the same. :) > On a pseudo-related topic: what should you use to find the absolute path > from root to your application directory when you need to include a file? > For example, I'm writing an application that has a function library in > 'app/lib/'. From any file in the application, at any directory level, I > want to be able to include specific files from the library. > > What's the best way to find '/absolute/path/from/root/' from > '/absolute/path/from/root/app/*/any_file.php'? > > Since the path you get from 'DOCUMENT_ROOT' isn't necessarily where the > executed file is (e.g., user directories), should that be avoided for > this type of task? Not sure if this will help either, but this is what I use to determine "where I'm at" in scripts I write. //System path to program $this->CONF['path'] = dirname($_SERVER['PATH_TRANSLATED']); //Determine protocol of web pages if(isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'ON') == 0) { $this->CONF['protocol'] = 'https://'; } else { $this->CONF['protocol'] = 'http://'; } //HTML address of this program $dir_name = dirname($_SERVER['SCRIPT_NAME']); if($dir_name == '\\') { $dir_name = ''; } $this->CONF['html'] = $this->CONF['protocol'] . $_SERVER['SERVER_NAME'] . $dir_name; //Determine web address of current page $this->CONF['current_page'] = $this->CONF['protocol'] . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; Then, if all of my methods, I use $this->CONF['path'] to include files relative to the file system and $this->CONF['html'] to include files relative to the HTML root. //Include a library file include($this->CONF['path'] . '/includes/db.inc'); //Path to image <img src="<?=$this->CONF['html']?>/images/picture.gif"> Hope that helps. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php