本文介绍了无法从URL PHP获取以#开头的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从URL获取ID.

I am trying to get the id from the URL.

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

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

但是,如果我在ID的开头使用#,那么我就没有ID.

But If I use # at the start of the id then I am not getting id.

URL: 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

If you want to use # as some value in url, you need to use url encoded version of # i.e %23, because # signifies an internal link to some section of the page. See https://www.yourhtmlsource.com/text/internallinks.html & https://way2tutorial.com/html/html_internal_links.php

如果您的网址是 http://localhost/user_notes/user.php?id =%231234 ,则您将在

中获得#

If your url is http://localhost/user_notes/user.php?id=%231234, then you'll get # in

echo $_GET['id'];

这篇关于无法从URL PHP获取以#开头的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 07:28