Jump to content


Photo

Confusing behavior from print and echo


  • Please log in to reply
3 replies to this topic

#1 spoofer26

spoofer26
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 09 April 2006 - 02:10 PM

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:
<?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>";


?>

Outputs this:
<a href='http://gamersphere.com/topclans/index.php?vote=418' target="_blank">                                                                                 </a>
(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.

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 April 2006 - 02:21 PM

I just tried your code. It works fine for me. Here is the HTML source generated:
<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>

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

#3 spoofer26

spoofer26
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 09 April 2006 - 02:30 PM

thanks ken, perhaps my php install has gone whacko. What version of PHP are you running?

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 April 2006 - 02:34 PM

I tried it on both version 4.3.9 (Linux) and 5.0.5 (Windows XP)

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users