用phpstudy2010安装了标题所示的php平台,
发现默认目录是在C盘的,
我想设置到其它盘去
但是奇怪的是,设置到其它盘之后
用PHP得到当前路径竟然,是C:\WINDOWS\system32\inetsrv
我是把默认站点的路径改成了我需要的路径。不能得到当前路径吗?是哪里问题?大家帮我看下,就下面这两句语句。$dir = './';
echo realpath($dir);

解决方案 »

  1.   

    先看一下函数说明:realpath
    (PHP 4, PHP 5)realpath — 返回规范化的绝对路径名说明
    string realpath ( string $path )
    realpath() 扩展所有的符号连接并且处理输入的 path 中的 '/./', '/../' 以及多余的 '/' 并返回规范化后的绝对路径名。返回的路径中没有符号连接,'/./' 或 '/../' 成分。 realpath() 失败时返回 FALSE,比如说文件不存在的话。在 BSD 系统上,如果仅仅是 path 不存在的话,PHP 并不会像其它系统那样返回 FALSE。 
    Example #1 realpath() 例子<?php
    $real_path = realpath("../../index.php");
    ?> 
      

  2.   

    再看一下linux下和WINDOWS下的区别:Please be aware that this function does NOT always strip a trailing slash!:LINUX (tested with PHP 5.2.11):
    ---
    realpath('.')
    : string = "/myhttpdfolder" 
    realpath('./')
    : string = "/myhttpdfolder" 
    realpath('fileadmin')
    : string = "/myhttpdfolder/fileadmin" 
    realpath('fileadmin/')
    : string = "/myhttpdfolder/fileadmin" WINDOWS (tested with PHP 5.2.5):
    ---
    realpath('.')
    : string = "C:\\myhttpdfolder" 
    realpath('./')
    : string = "C:\\myhttpdfolder\\" 
    realpath('fileadmin')
    : string = "C:\\myhttpdfolder\\fileadmin" 
    realpath('fileadmin/')
    : string = "C:\\myhttpdfolder\\fileadmin\\"