URL Manipulation


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.