Jump to content

Confusing behavior from print and echo


spoofer26

Recommended Posts

Hi, im not technically a novice at PHP but since my problem involves printing to the browser i guess this is the place.

can anyone explain why this:
[code]
<?php

$test="img_id=2";

echo  "<a href='http://gamersphere.com/topclans/index.php?vote=418' target='_blank'><img src='http://gamersphere.com/topclans/index.php?".$test."&img=418' border='0'></a>";


?>
[/code]

Outputs this:
[code]
<a href='http://gamersphere.com/topclans/index.php?vote=418' target="_blank">                                                                                 </a>
[/code]
(ie, for some reason the <img> tag is being turned to whitespace by the php parser).


Is this expected behavior? it makes absolutely no sense to me.
Link to comment
https://forums.phpfreaks.com/topic/6941-confusing-behavior-from-print-and-echo/
Share on other sites

I just tried your code. It works fine for me. Here is the HTML source generated:
[code]<a href='http://gamersphere.com/topclans/index.php?vote=418' target='_blank'><img src='http://gamersphere.com/topclans/index.php?img_id=2&img=418' border='0'></a>[/code]

You can see it in action at [a href=\"http://localhost/kenrbnsn/phpfreaks/quest.php\" target=\"_blank\"]http://localhost/kenrbnsn/phpfreaks/quest.php[/a]

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.