HI,

I am a ASP developer. Just now I came to PHP.
In asp we have something like Server.mappath() function.
Syntax: Server.mappath("/data/")
if I give the path address as given above then it will return the physical path of the data folder ie eg: c:\inetpub\wwwroot\data.

I want to know the is there any similar function in php to map the physical path of the folder or a file.

any help.... thanx in adv

rgds
Ural

    4 months later

    $A = $PATH_TRANSLATED;
    $B = strrev ($A);
    $C = strstr ($B ,'\');
    $D = strrev ($C);

    / In $D you will get the path /

      5 months later

      I also am looking for the equivalent. So far there is none that will accept a VIRTUAL (not relative) path and resolve it to an absolute path (i.e. slash-name-slash: "/path/", and not name-slash: "path/").

      Server.MapPath("/data/") might resolve to C:\data if the script is executed from ServerA and F:\data (network share) if executed from ServerB, where ServerA and ServerB are load balanced servers representing a single IP.

        22 days later

        This isn't what he was asking for. That function will give you the absolute path of the current directory, but it won't give you the path of an aribitrary virtual directory. That is, we are looking for something like "PATH_TRANSLATED" that doesn't assume we are referring to the current path.

        Giri Raj wrote:

        $A = $PATH_TRANSLATED;
        $B = strrev ($A);
        $C = strstr ($B ,'\');
        $D = strrev ($C);

        / In $D you will get the path /

          7 months later

          I found a simple solution for this. The following class can help.

          $Server = new Server;
          $Server->MapPath("/something/other.php");

          class Server{

          var $root_path;

          function Server(){
          $physical_path = $GLOBALS['PATH_TRANSLATED'];
          $this_path = $GLOBALS['PATH_INFO'];
          $physical_path = str_replace("\\","\",$physical_path);
          $sub_url = str_replace("/","\\",$this_path);
          $this->root_path = split($sub_url,$physical_path);
          $this->root_path = $this->root_path[0];
          }

          function MapPath($based_url){
          $unmapped_url = str_replace("/","\",$based_url);
          $mapped_url = $this->root_path.$unmapped_url;
          $mapped_url = str_replace("\","\\",$mapped_url);
          return $mapped_url;
          }

          }

            Write a Reply...