Jump to content

Archived

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

spoofer26

Confusing behavior from print and echo

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
I tried it on both version 4.3.9 (Linux) and 5.0.5 (Windows XP)

Ken

Share this post


Link to post
Share on other sites

×

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.