php获取当前页面url地址及参数

要获取当前页面的完整地址我们要经过很多操作如http或https,php文件与路径,主机域名,查询参数最后就成了。

获取协议-http:url的协议,可以读出在$ _server ['server_protocol']变量。

  1. */ 
  2. echo $_server['server_protocol']; 
  3. /* 
  4. 如果你检查值,可以发现,不只是http或https,但这样的字符串:http/1.1的 
  5. */ 
  6. $protocol = strpos(strtolower($_server['server_protocol']),'https')  === false ? 'http' : 'https'
  7. /* 
  8. 获取主机域名*/ 
  9. $host = $_server['http_host']; 
  10. /* 
  11. 利用$ _server['script_name']获取除域名外的php文件与路径 
  12. */ 
  13. $script = $_server['script_name']; 
  14.  
  15. //获取?后面查询参数 
  16. $params = $_server['query_string']; 
  17.  
  18. //方法二 
  19. $uri = $_server['request_uri']; 
  20. //下面来看一个完整的获取当前url实例 
  21. $protocol = strpos(strtolower($_server['server_protocol']),'https')   === false ? 'http' : 'https'
  22. $host     = $_server['http_host']; 
  23. $script   = $_server['script_name']; 
  24. $params   = $_server['query_string'];  
  25. $currenturl = $protocol . '://' . $host . $script . '?' . $params
  26. echo $currenturl
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » php获取当前页面url地址及参数

42 评论

  1. imdur medication buy digoxin generic order telmisartan 20mg without prescription

  2. simvastatin 20mg over the counter proscar tablet finasteride online buy

  3. buy generic nifedipine 10mg adalat price buy allegra 120mg

  4. purchase carvedilol online oxybutynin us amitriptyline drug

  5. buy nexium 20mg without prescription biaxin 250mg pill order furosemide 100mg

  6. tadalafil 10mg sale levitra discount buy erectile dysfunction medications

  7. accutane 20mg pills isotretinoin cheap buy zithromax 250mg without prescription

  8. albuterol online augmentin pills buy clavulanate without prescription

  9. order imuran 25mg online cheap naprosyn sale order naproxen 250mg pill

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡