[英]How to use ampersands in PHP GET URL variable (or function argument)?
I've got the following code (this is WordPress function) (example of wrong structure): 我有以下代码(这是WordPress函数)(错误结构的例子):
<?php paginate_comments_links('prev_text=← Older&next_text=Newer →'); ?>
Example of correct structure: 结构正确的例子:
<?php paginate_comments_links('prev_text=Older&next_text=Newer'); ?>
As you can see I'm trying to add preceding arrow + space ( ←
) to 'Older' word and space + arrow ( →
) to 'Newer' word. 正如您所看到的,我正在尝试将前一个箭头+空格( ←
)添加到'较早'单词和空格+箭头( →
)为'较新'单词。 The problem is that there is a conflict between & that separates 2 function arguments and & that is the beginning of HTML character. 问题是&之间存在冲突,它将2个函数参数分开,而且是HTML字符的开头。
How should correct structure look like? 正确的结构应该如何?
In case someone searches for the same question: 如果有人搜索相同的问题:
In order to pass a parameter with ampersands (&), you need to encode it. 为了传递带符号(&)的参数,您需要对其进行编码。
use urlencode()
使用urlencode()
Source : http://php.net/manual/en/function.urlencode.php 资料来源: http : //php.net/manual/en/function.urlencode.php
To decode it afterward, use: urldecode()
要在之后解码它,请使用: urldecode()
Source : http://php.net/manual/en/function.urldecode.php 资料来源: http : //php.net/manual/en/function.urldecode.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.