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

Unable to get id starting with # from URL PHP

我正在尝试从 URL 获取 ID。

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

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

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

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

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

如果您想使用 # 作为 url 中的某个值,您需要使用 # 的 url 编码版本,即 %23,因为# 表示页面某些部分的内部 link。参见 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'];