In PHP 7.4.3 parsing the following URL using parse_url()
returns false
:
/search/publication_year:2019
In the documentation it says that:
On seriously malformed URLs, parse_url() may return false.
Seems like it considers URLs that include :
followed by a number to be “seriously malformed”.
Any ideas how to get around this issue ?
Advertisement
Answer
parse_url() sometimes gives unreliable results when not passing in a full URL – try adding the domain and protocol – you’ll see in my examples below that if I put http://www.google.com/ in the expected response comes back.
There was also a bug in php 5.4 that incorrectly returned false when a colon was present.
See:
https://www.tehplayground.com/okoFSmISFCKNYaav
For some example output from parse_url