磅符号(#)在PHP中不起作用 [英] Pound sign (#) not working in PHP

查看:117
本文介绍了磅符号(#)在PHP中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有变量'cno',它的值有时有 123# - (以英镑符号结尾。)

问题是,在传递URL后,我无法用磅符号变量。



ex:my url - /index.php所以我需要得到 $ _ GET ['cno'] c> value like = 34#,但它只显示 34 可能通过磅符号来获得'cno'变量值。



谢谢。

解决方案

您必须将编码为%23 ,因此您的网址如下所示:


/index.php?cno=34%23


为了更容易使用PHP的内置 urlencode 函数: http://php.net/urlencode

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


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.

解决方案

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"

这篇关于磅符号(#)在PHP中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆