Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is parse_url returning fragment?

Tags:

php

parse-url

I have the following URL:
http://sub.mysite.com/store/?store=Fine+Ting&storeid=3726&test1=value1&test2=value2

Using print_r(parse_url($url)) gives me this:

Array ( 
  [scheme] => http 
  [host] => sub.mysite.com 
  [path] => /store/ 
  [query] => store=Fine+Ting& 
  [fragment] => 038;storeid=3726&test1=value1&test2=value2 
) 

According to the documentation I should only get fragment after the hashmark #.

Why then is parse_url returning fragment? Shouldn't that be in [query]?

like image 743
Steven Avatar asked Nov 02 '11 21:11

Steven


1 Answers

You have a problem with you url, the ampersand is encoded in htmlentities (&). Therefore parse_str thinks, the fragment is starting there.

Try using html_entity_decode before passing the url to parse_url.

like image 189
mAu Avatar answered Oct 31 '22 05:10

mAu