URL操作

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了URL操作相关的知识,希望对你有一定的参考价值。

  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.

以上是关于URL操作的主要内容,如果未能解决你的问题,请参考以下文章

JS操作URL

URL 操作

操作 url 参数 Restful API

模板操作 url 中的 NoReverseMatch

CakePHP 从 URL 中删除索引操作

天气休息 api 的 URL 操作