Posted By

Tamedo on 12/01/08


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

luggnagger


PHP GET URL


 / Published in: PHP
 

  1. <?php
  2. function curPageURL() {
  3. $pageURL = 'http';
  4. if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  5. $pageURL .= "://";
  6. if ($_SERVER["SERVER_PORT"] != "80") {
  7. $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  8. } else {
  9. $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  10. }
  11. return $pageURL;
  12. }
  13. ?>
  14.  
  15. <?php
  16. echo curPageURL();
  17. ?>
  18.  
  19. <?php
  20. function curPageName() {
  21. return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
  22. }
  23.  
  24. echo "The current page name is ".curPageName();
  25. ?>

Report this snippet  

You need to login to post a comment.