Thursday, 15 September 2011

PHP Getting server url parameters -


I am using the following function to get my server URL:

  / * Get url parameter * / function url () {return sprint ("% s: //% s% s", continue ($ _ server ['HTTPS']) and $ _SERVER ['HTTPS']! = 'Off'? 'Https': 'http', $ _SERVER ['SERVER_NAME'], $ _SERVER ['REQUEST_URI']); }  

The following is my URL:

  http://enunua.com/emarps/recover_password.php  

From the above URL, I want the following parameters only as part of my URL:

  http://enunua.com/emarps/  

Except that recovery_password.php but the above function gives me the full URL of retrieved_password.php, please advise how can I get only:? You are using $ _SERVER ['REQUEST_URI'], which includes the entire request-URL, which is "recover_password.php" You can use STH like "strrpos" to get the URL without the filename.

Try to use it:

  function url () {return sprintf ("% s: //% s" Https': 'http', $ _SERVER ['SERVER_NAME'], substart ($$), "% s", $ (server $ [$ HTTPS ']) & amp; _SERVER [' REQUEST_URI '], 0, stropo ($ _ server [' REQUEST_URI '], '/') + 1)); }  

No comments:

Post a Comment