Guest User

Untitled

a guest
Jan 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. $parsedUrl = parse_url($uri);
  2. // if the uri has no scheme, it won't think there's a host and will give bad results
  3. if ($parsedUrl !== false && !isset($parsedUrl['host'])) {
  4. // double slash prepended will parse $uri as if it has a schema and no schema will be in the result
  5. $parsedUrl = parse_url('//' . $uri);
  6. }
  7. if ($parsedUrl === false) {
  8. throw new MalformedUrlException('Malformed URL: ' . $uri);
  9. }
  10. // use parsed url as needed
Add Comment
Please, Sign In to add comment