note 32059 modified in function.dirname by vincent

From: Date: Sat, 30 Aug 2003 11:22:01 +0000
Subject: note 32059 modified in function.dirname by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55339@lists.php.net to get a copy of this message
This one will put both the "www" and "file" path into an easy to transport array. <?php // build the www path: $me = $_SERVER['PHP_SELF']; $Apathweb = explode("/", $me); $myFileName = array_pop($Apathweb); $pathweb = implode("/", $Apathweb); $myURL = "http://".$_SERVER['HTTP_HOST'].$pathweb."/".$myFileName; $PAGE_BASE['www'] = $myURL; // build the file path: strstr( PHP_OS, "WIN") ? $strPathSeparator = "\\" : $strPathSeparator = "/"; $pathfile = getcwd (); $PAGE_BASE['physical'] = $pathfile.$strPathSeparator.$myFileName; // this is so you can verify the results: $www = $PAGE_BASE['www']; $physical = $PAGE_BASE['physical']; echo "$physical<p>"; echo "$www<p>"; ?> The following will return something like: Windows: F:\dev\Inetpub\wwwroot\somedirectory\index.php http://devserver/somedirectory/index.php Unix: /home/somepathto/gieson.com/webroot/index.php http://www.gieson.com/index.php --was-- This one will put both the "www" and "file" path into an easy to transport array. <?php // build the www path: $me = $_SERVER['PHP_SELF']; $Apathweb = explode("/", $me); $myFileName = array_pop($Apathweb); $pathweb = implode("/", $Apathweb); $myURL = "http://".$_SERVER['HTTP_HOST'].$pathweb."/".$myFileName; $PAGE_BASE['www'] = $myURL; // build the file path: strstr( PHP_OS, "WIN") ? $strPathSeparator = "\\" : $strPathSeparator = "/"; $pathfile = getcwd (); $PAGE_BASE['physical'] = $pathfile.$strPathSeparator.$myFileName; // this is so you can verify the results: $www = $PAGE_BASE['www']; $physical = $PAGE_BASE['physical']; echo "$physical<p>"; echo "$www<p>"; The following will return something like: Windows: F:\dev\Inetpub\wwwroot\somedirectory\index.php http://devserver/somedirectory/index.php Unix: /home/somepathto/gieson.com/webroot/index.php http://www.gieson.com/index.php ?> http://www.php.net/manual/en/function.dirname.php

« previous php.notes (#55339) next »