note 87837 added to function.parse-url

From: Date: Thu, 25 Dec 2008 20:34:34 +0000
Subject: note 87837 added to function.parse-url
Groups: php.notes 
Request: Send a blank email to php-notes+get-148506@lists.php.net to get a copy of this message
I noticed the parse_url function basically fails big time when you don't have a scheme. $str='www.cow.com?thisworks=false'; $array=parse_url($str); ( [path] => www.cow.com [query] => thisworks=false ) So, it assumes the input is a relative url if it doesn't have a scheme. However, this is not what I want - while all the URLs I'm processing are not local, they may or may not have http://. I could first check for that with strpos and append if necessary, but why not have a function that just works regardless? The ones provided below (parseUrl) work just right, with or without a scheme. Thanks! php > print_r($array); Array ( [0] => www.cow.com?thisworks=true [scheme] => [1] => [login] => [2] => [pass] => [3] => [host] => www.cow.com [4] => www.cow.com [subdomain] => www [5] => www [domain] => cow.com [6] => cow.com [extension] => com [7] => com [port] => [8] => [path] => [9] => [file] => [10] => [arg] => thisworks=false [11] => thisworks=false ) ---- Server IP: 209.41.74.194 Probable Submitter: 71.10.64.64 ---- Manual Page -- http://www.php.net/manual/en/function.parse-url.php Edit -- https://master.php.net/note/edit/87837 Del: integrated -- https://master.php.net/note/delete/87837/integrated Del: useless -- https://master.php.net/note/delete/87837/useless Del: bad code -- https://master.php.net/note/delete/87837/bad+code Del: spam -- https://master.php.net/note/delete/87837/spam Del: non-english -- https://master.php.net/note/delete/87837/non-english Del: in docs -- https://master.php.net/note/delete/87837/in+docs Del: other reasons-- https://master.php.net/note/delete/87837 Reject -- https://master.php.net/note/reject/87837 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148506) next »