URL functions (PHP)


SUBMITTED BY: scripts4you

DATE: Oct. 21, 2015, 8:59 a.m.

FORMAT: Text only

SIZE: 639 Bytes

HITS: 1825

  1. // parse_url:
  2. $url = "http://www.jonasjohn.de/post.php?example=yes&text=foobar";
  3. $url = parse_url($url);
  4. print_r($url);
  5. /*
  6. will return this array:
  7. [scheme] => http
  8. [host] => www.jonasjohn.de
  9. [path] => /post.php
  10. [query] => example=yes&text=foobar
  11. */
  12. // urldecode & urlencode:
  13. $query = "example=yes&text=foo%28bar%29%2B";
  14. print urldecode($query); // opposite: urlencode
  15. // output: example=yes&text=foo(bar)+
  16. // parse the query:
  17. parse_str($query, $output);
  18. print_r($output);
  19. /*
  20. will return this array:
  21. [example] => yes
  22. [text] => foo(bar)+
  23. */

comments powered by Disqus