Page 1 of 1

Quoted string with angle bracket won't print without space

Posted: Sun Sep 27, 2009 9:54 pm
by joeshmoe666
This is driving me nuts.. I know it's something really obvious but when I run this code it prints nothing :

<?php
$Test="hello";
$request="<a";
print_r($request);
exit;
?>

The only way it prints is if I put a space after the angle bracket like this:

<?php
$Test="hello";
$request="< a";
print_r($request);
exit;
?>

Anyone know what the problem is ??

Thanks in advance
Joe

Re: Quoted string with angle bracket won't print without space

Posted: Sun Sep 27, 2009 10:09 pm
by requinix
The <a is there - you're just not seeing it. It's being interpreted as HTML markup. Check the HTML source of the page.

Code: Select all

$request=htmlentities("<a"); // <a

Re: Quoted string with angle bracket won't print without space

Posted: Sun Sep 27, 2009 10:42 pm
by joeshmoe666
Afraid that's not it .. put any character instead of the a and it still does the same thing .. and even if it were reading it as html it should still output it since it's a quoted string..

Re: Quoted string with angle bracket won't print without space

Posted: Sun Sep 27, 2009 10:44 pm
by Eran
did you try it?

Re: Quoted string with angle bracket won't print without space

Posted: Sun Sep 27, 2009 11:30 pm
by joeshmoe666
Sorry .. you're right .. the original problem was I was sending XML to a server and getting an error so I was trying to print out the xml to my screen so I could see if it was formed correctly .. and of course you're right that you can't view the xml that way since it has the < in it .. I can print it to the screen and view it with page source though .. so now I can get back to the original problem .. interesting side track though .. arghh!!

Thanks