Pound sign (#) not working in PHP(英镑符号 (#) 在 PHP 中不起作用)
问题描述
我有变量 'cno',它的值有时有 123#
- (以井号结尾.)
I have variable 'cno' and it's values sometimes have 123#
- ( end with pound sign. )
问题是,在传递 URL 后,我无法获得带有井号的变量.
The problem is, after passing the URL I couldn't get variable with pound sign.
例如:我的网址 - /index.php?cno=34#
ex: my url - /index.php?cno=34#
所以我需要获得 $_GET['cno']
值,比如 = 34#
,但它只显示 34
So I need to get $_GET['cno']
value like = 34#
, but it only display 34
是否可以得到带有井号的cno"变量值.
Is it possible to get 'cno' variable value with pound sign.
谢谢.
推荐答案
您必须将 #
编码为 %23
,因此您的 URL 将如下所示:
You'll have to encode the #
as %23
, so your URL would look like this:
/index.php?cno=34%23
/index.php?cno=34%23
为了更容易使用 PHP 的内置 urlencode
函数:http://php.net/urlencode
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"
这篇关于英镑符号 (#) 在 PHP 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:英镑符号 (#) 在 PHP 中不起作用


基础教程推荐
- 使用 PDO 转义列名 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01