dsavz66262 2013-12-23 22:49
浏览 16

basename没有给我完整的URL PHP

Right now I'm printing the current URL I have and it kinda does it ok:

$currentURL = basename($_SERVER['PHP_SELF']);

The problem is that it only prints

solutions.php

instead of printing

solutions.php?id=581298a7-6c08-11e3-9bea-742f689f29f1

Anybody knows why this is happening? I need to get to print the part of

?id=581298a7-6c08-11e3-9bea-742f689f29f1

Because then I will be performing a substring to get just the ID.

  • 写回答

2条回答 默认 最新

  • dongyunque2511 2013-12-23 22:52
    关注

    Use parse_url, which parses a URL and returns its various components in a usable array. You'll also want to make sure you're parsing the correct string; in this case use:

    $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    

    Full usage:

    $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    print_r(parse_url($url));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决