$path_parts = pathinfo("/www/htdocs/index.html");
echo $path_parts["dirname"] . "\n";目录名
echo $path_parts["basename"] . "\n";文件名
echo $path_parts["extension"] . "\n";扩展名

解决方案 »

  1.   

    $path_parts   =   pathinfo("/www/htdocs/index.html"); 
    echo   $path_parts["dirname"]   .   "\n";目录名 
    echo   $path_parts["basename"]   .   "\n";文件名 
    echo   $path_parts["extension"]   .   "\n";扩展名
      

  2.   


    function get_content_type($url)
    {
    $url = str_replace(" ", "%20", $url);
    $TheURL_header = substr($url, 0, 7);
    if($TheURL_header == "http://")
    {
    $pos = strpos($url, "/", 7);
    if($pos)
    {
    $host = substr($url, 7, $pos - 7);
    }
    else
    {
    $host = substr($url, 7);
    }
    $referer = "http://".$host."/";
    }
    else
    {
    //---- 不是http连接 ----
    return false;
    }
    $TheURL_footer = substr($url, strlen("http://".$host."/"));
    $http_header = "";
    $http_header .= "HEAD /".$TheURL_footer." HTTP/1.1\r\n";
    $http_header .= "Host: ".$host."\r\n";
    $http_header .= "Connection: close\r\n";
    $http_header .= "Cache-Control: no-cache\r\n";
    $http_header .= "\r\n";
    $data = "";
    $bytes = 0;
    $fp = @fsockopen($host, 80, $errno, $errstr, 30);
    if (!$fp)
    {
    //---- 连不上 ----
    return false;
    }
    fwrite($fp, $http_header);
    $CRLF = "\x0d"."\x0a"."\x0d"."\x0a";
    while(!feof($fp))
    {
    //---- 读文件字节流 ----
    $tmp_stream = fgets($fp, 1280);
    $stream_header = substr($tmp_stream, 0, 9);
    $stream_header = strtolower($stream_header);
    if($stream_header == "location:")
    {
    //---- 转走了 ----
    $remote_url = substr($tmp_stream, 9);
    $remote_url = trim($remote_url);
    $the_url_header = substr($remote_url, 0, 7);
    if($the_url_header != "http://")
    {
    if(substr($remote_url, 0, 1) == "/")
    {
    $remote_url = substr($remote_url, 1);
    $remote_url = "http://".$host.$remote_url;
    }
    else
    {
    $pos_url = strrpos($url, "/");
    $remote_url = substr($url, 0, $pos_url)."/".$remote_url;
    }
    }
    fclose($fp);
    return get_redirect_url($url);
    }
    $stream_header = substr($tmp_stream, 0, 13);
    $stream_header = strtolower($stream_header);
    if($stream_header == "content-type:")
    {
    $type = substr($tmp_stream, 13);
    $type = trim($type);
    return $type;
    }
    if($tmp_stream == "\r\n")
    {
    //---- 头部信息结束 ----
    break;
    }
    }
    return false;
    }
    echo get_content_type("http://zi.csdn.net/zhangxx.gif");
      

  3.   

    上面第60几行错了,应该是 return get_content_type($url);