Pound sign (#) not working in PHP

人盡茶涼 提交于 2019-12-29 01:26:32

问题


I have variable 'cno' and it's values sometimes have 123# - ( end with pound sign. )

The problem is, after passing the URL I couldn't get variable with pound sign.

ex: my url - /index.php?cno=34#

So I need to get $_GET['cno'] value like = 34#, but it only display 34

Is it possible to get 'cno' variable value with pound sign.

thanks.


回答1:


You'll have to encode the # as %23, so your URL would look like this:

/index.php?cno=34%23

To make it easier use PHP's built-in urlencode function: http://php.net/urlencode

$cno = "34#";
$url = urlencode("/index.php?cno=" . $cno); // "/index.php?cno=34%23"



回答2:


# in a URL indicates a document fragment. URL-encode your values before sending them.



来源:https://stackoverflow.com/questions/7479638/pound-sign-not-working-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!