parse_url在5.3中无法正常工作

时间:2014-02-28 06:05:34

标签: php parse-url

我需要解析php中的url。 url以//开头在php 5.5中正确解析但在5.3中没有正确解析。 php 5.3确实将“host”返回为null,并返回带有“path”路径的域。我正在获取url表单远程站点。我也得到像“//images/mdb_shoppingBag.png”这样的网址。为此,我需要在网址前添加主机名。所以,我无法添加http://。有没有解决方案?

<?php 
    $sty = '//dimg.dillards.com/is/image/DillardsZoom/03707963_zi?$c7product$';
    print_r( parse_url($sty) );
?>

And the output is

in PHP 5.5
Array ( [host] => dimg.dillards.com [path] => /is/image/DillardsZoom/03707963_zi [query] => $c7product$ )

in PHP 5.3
Array ( [path] => //dimg.dillards.com/is/image/DillardsZoom/03707963_zi [query] => $c7product$ )

0 个答案:

没有答案