Strange behavior with parse_url and different protocols
P粉771233336
P粉771233336 2024-02-17 22:43:36
0
1
541

I tried to use parse_url to decode the DSN and noticed a strange behavior. The following is an example DSN:

parse_url('redis://localhost'); //Correctly parses
parse_url('file:///var/sessions'); //Correctly parses
parse_url('redis:///var/run/redis.sock'); //Parse error
parse_url('file:///var/run/redis.sock'); //Correctly parses

Looks like it can't resolve urls without a host, except for the file scenario.

Did I miss something?

Is there a way to disable this behavior?

P粉771233336
P粉771233336

reply all(1)
P粉512526720

The manual for

parse_url() mentions that you cannot use this function with URIs. Specifically, when your scheme has triple slashes, it is defined as "invalid" and this function returns false:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!