note 118134 added to function.parse-url

From: Date: Mon, 12 Oct 2015 16:40:50 +0000
Subject: note 118134 added to function.parse-url
Groups: php.notes 
Request: Send a blank email to php-notes+get-203938@lists.php.net to get a copy of this message
This function will attempt to parse relative URLs but relaying on it can produce unexpected behavior that can cause some hard to track bugs. (The following results are obtained from PHP 5.5.19) Attempting to parse a url like this http://example.com/entities/GOA:98/?search=8989157d1f22 Correctly produces <?php array ( 'scheme' => 'http', 'host' => 'example.com', 'path' => '/entities/GOA:98/', 'query' => 'search=8989157d1f22', ); ?> However, Attempting to parse the relative URL entities/GOA:98/?search=8989157d1f22 <?php array ( 'host' => 'entities', 'port' => 98, 'path' => '/GOA:98/', 'query' => 'search=8989157d1f22', ) ?> If I change :98 to :A98 parse_url parses the URL correctly as <?php array ( 'path' => 'entities/GOA:A98/', 'query' => 'search=8989157d1f22', ) ?> Bottom line, Avoid using parse_url for relative urls unless you have tested the expected input and you know parse_url will handle them well. ---- Server IP: 72.52.91.14 Probable Submitter: 64.134.172.181 ---- Manual Page -- http://php.net/manual/en/function.parse-url.php Edit -- https://master.php.net/note/edit/118134 Del: integrated -- https://master.php.net/note/delete/118134/integrated Del: useless -- https://master.php.net/note/delete/118134/useless Del: bad code -- https://master.php.net/note/delete/118134/bad+code Del: spam -- https://master.php.net/note/delete/118134/spam Del: non-english -- https://master.php.net/note/delete/118134/non-english Del: in docs -- https://master.php.net/note/delete/118134/in+docs Del: other reasons-- https://master.php.net/note/delete/118134 Reject -- https://master.php.net/note/reject/118134 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203938) next »