gpt4 book ai didi

php - 无法从 URL PHP 获取以# 开头的 ID

转载 作者:行者123 更新时间:2023-12-04 15:04:47 25 4
gpt4 key购买 nike

我正在尝试从 URL 中获取 ID。

网址:http://localhost/user_notes/user.php?id=1234

echo $_GET['id']; // outputs 1234    

但是如果我在 id 的开头使用 # 那么我就得不到 id。

网址:http://localhost/user_notes/user.php?id=#1234

echo $_GET['id']; // outputs nothing  

最佳答案

如果你想使用 # 作为 url 中的某个值,你需要使用 # 的 url 编码版本,即 %23,因为# 表示指向页面某些部分的内部链接。参见 https://www.yourhtmlsource.com/text/internallinks.html & https://way2tutorial.com/html/html_internal_links.php

如果你的 url 是 http://localhost/user_notes/user.php?id=%231234,那么你会得到 #

echo $_GET['id'];

关于php - 无法从 URL PHP 获取以# 开头的 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66380405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com