Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 简单的html dom和Net URL2规范化相对路径_Php_Relative Path_Simple Html Dom - Fatal编程技术网

Php 简单的html dom和Net URL2规范化相对路径

Php 简单的html dom和Net URL2规范化相对路径,php,relative-path,simple-html-dom,Php,Relative Path,Simple Html Dom,我正在尝试使用和规范化到完整URL的相对路径,像这样的路径由脚本规范化,例如:src=“/my\u path”,但是像这样的路径:src=“my\u path”不是!如何规范化这样的路径 例如: $uri = new Net_URL2("http://test.com"); print $uri->resolve('/my_path') . "\n"; // works print $uri->resolve('my_path') . "\n"; // doesn't work!

我正在尝试使用和规范化到完整URL的相对路径,像这样的路径由脚本规范化,例如:
src=“/my\u path”
,但是像这样的路径:
src=“my\u path”
不是!如何规范化这样的路径

例如:

$uri = new Net_URL2("http://test.com");
print $uri->resolve('/my_path') . "\n"; // works
print $uri->resolve('my_path') . "\n";  // doesn't work!

您描述的是Net_URL2中的一个已知错误:

票证有一个补丁可以修复它,但是它还没有在pear包中修复。补丁:

Index: Net/URL2.php
===================================================================
--- Net/URL2.php    (revision 323857)
+++ Net/URL2.php    (revision )
@@ -720,7 +720,7 @@
                     } else {
                         // Merge paths (RFC 3986, section 5.2.3)
                         if ($this->_host !== false && $this->_path == '') {
-                            $target->_path = '/' . $this->_path;
+                            $target->_path = '/' . $reference->_path;
                         } else {
                             $i = strrpos($this->_path, '/');
                             if ($i !== false) {

您描述的是Net_URL2中的一个已知错误:

票证有一个补丁可以修复它,但是它还没有在pear包中修复。补丁:

Index: Net/URL2.php
===================================================================
--- Net/URL2.php    (revision 323857)
+++ Net/URL2.php    (revision )
@@ -720,7 +720,7 @@
                     } else {
                         // Merge paths (RFC 3986, section 5.2.3)
                         if ($this->_host !== false && $this->_path == '') {
-                            $target->_path = '/' . $this->_path;
+                            $target->_path = '/' . $reference->_path;
                         } else {
                             $i = strrpos($this->_path, '/');
                             if ($i !== false) {