3

我有以下代码(这是 WordPress 函数)(结构错误的示例):

<?php paginate_comments_links('prev_text=&#x2190;&nbsp;Older&next_text=Newer&nbsp;&#x2192;'); ?>

正确结构示例:

<?php paginate_comments_links('prev_text=Older&next_text=Newer'); ?>

如您所见,我正在尝试将前面的箭头 + 空格 ( &#x2190;&nbsp;) 添加到“旧”单词,并将空格 + 箭头 ( &nbsp;&#x2192;) 添加到“较新”单词。问题是分隔两个函数参数的 & 和 HTML 字符开头的 & 之间存在冲突。

正确的结构应该是什么样子?

4

1 回答 1

8

In case someone searches for the same question:

In order to pass a parameter with ampersands (&), you need to encode it.

use urlencode()

Source : http://php.net/manual/en/function.urlencode.php


To decode it afterward, use: urldecode()

Source : http://php.net/manual/en/function.urldecode.php

于 2012-02-28T20:59:03.417 回答