PHP变量在html中显示为空。神秘的

PHP变量在html中显示为空。神秘的,php,debugging,Php,Debugging,我有一个疯狂的情况,我无法理解: 我有这个字符串: $description = "<a href='".$link."'><img src='".$image."' border=0 ></a>".$description; $description=”“.$description; 有时打印输出看起来像这样: <a href='http://www.domain.com'><img src='http://www.domain.com

我有一个疯狂的情况,我无法理解:

我有这个字符串:

$description = "<a href='".$link."'><img src='".$image."' border=0 ></a>".$description;
$description=”“.$description;
有时打印输出看起来像这样:

<a href='http://www.domain.com'><img src='http://www.domain.com/image.jpg' border=0 ></a> Other Text
其他文本
其他时候看起来是这样的

<a href=''><img src='' border=0 ></a> Other Text
其他文本
我会认为我的变量发生了什么,但如果我做了以下事情:

  $description = $link."<a href='".$link."'><img src='".$image."' border=0 ></a>".$description;
$description=$link.“$description;
然后它100%的时间在html前面输出$link变量:

http://www.domain.com<a href=''><img src='' border=0 ></a> Other Text
http://www.domain.com 其他文本
发生什么事了

---解决---


我的解析脚本在删除链接时表现不正常。解决方案应该是直观的,但我认为字符串没有通过任何其他函数运行。太多了。谢谢你的支持!对于那些偶然发现这一点的人,请检查您的解析功能

您可能拼错了第二个链接变量。当这种情况发生时,PHP不会警告您,但会默默地给您一个新的空变量

在您同时为
$description
赋值的行末尾的
$description
的目的是什么?如果我用PHP执行你的第一行,我的解释器会抱怨

  PHP Notice:  Undefined variable: description in C:\Temp\test.php on line 4

您确定每次执行该行时,
$description
已经有一个值了吗?

检查$link变量中的内容,就好像其中有任何内容一样,它可能会中断html。该符号或任何其他符号。

打开错误报告以在开发过程中查看更多信息

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

我不相信你的第三个例子。