search

Home  >  Q&A  >  body text

Strange behavior with parse_url and different protocols

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粉771233336P粉771233336313 days ago610

reply all(1)I'll reply

  • P粉512526720

    P粉5125267202024-02-18 16:56:03

    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:

    reply
    0
  • Cancelreply