Posted By

llbbl on 06/19/07


Tagged

url php textmate variables server


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

basicmagic
hudge
silverbux
prismatiq


URL Manipulation


 / Published in: PHP
 

  1. $a = $_SERVER['HTTP_HOST'] // server-name - domain
  2. $b = $_SERVER['PHP_SELF'] // you're page, as you know
  3. $c = $_SERVER['QUERY_STRING'] // everything after the "?",
  4. // but not including the "?"
  5.  
  6. echo "$a$b?$c"; // would print whole URL
  7.  
  8. $d = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
  9. // notice the "?" in middle of the above, and variables seprated by dots(.)
  10. // $_SERVER['QUERY_STRING'] reads url GET query, but does not contain
  11. // the "?" in it itself, since "?" is not a variable.
  12.  
  13. echo $d; // would print the whole URL using above.

Report this snippet  

You need to login to post a comment.