开发者

PHP Variables show blank if in html. MYSTERY

I have a crazy situation that I cannot figure out:

开发者_运维百科I have this string:

$description = "<a href='".$link."'><img src='".$image."' border=0 ></a>".$description;

and sometimes the printout looks like this:

<a href='http://www.domain.com'><img src='http://www.domain.com/image.jpg' border=0 ></a> Other Text

and other times it looks like this.

<a href=''><img src='' border=0 ></a> Other Text

I would think that something is happening to my variables, but if I do the following:

  $description = $link."<a href='".$link."'><img src='".$image."' border=0 ></a>".$description;

then it outputs the $link variable in front of the html 100% of the time:

http://www.domain.com<a href=''><img src='' border=0 ></a> Other Text

What is going on!?

--- SOLVED ---

I had parsing scripts that were misbehaving removing the links. The solution should of been intuitive but I thought the string was not being ran through any other functions. too many LOC. Thanks for the support! For those of you who stumble upon this check your parsing functions!


Turn error reporting on to see more information during development...

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


You might have misspelled the second link variable. PHP will not warn you when this happens, but will silently give you a new, empty variable.


What is the intention of that .$description at the end of the line in which you're also assigning a value to $description? If I execute your first line in PHP, my interpreter complaints with

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

Are you sure that $description has already a value each time you execute that line?


Check what's in your $link variable as if you have any 's in it it may be interrupting your html. That or any other symbols.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜