tags:

views:

114

answers:

2

Here is my exact code.

<?php
echo "<! <";
?>

And this is the returned string.

<! >

Why is the last character changing?

+7  A: 

I have created an identical script as that detailed by the OP.

In Firefox v3.6.3, the browser displays <! <.

In Google Chrome v4.1, the browser display is blank, but the source shows <! >.

In Internet Explorer 8, the browser displays <! <.

In Opera v10.53, the browser displays < and the source shows <! <.

Not sure which browser you are having difficulties in, or, for that matter, why you would be wanting to display these characters in a browser window.

If you are wanting these characters to be displayed, literally, then using something like htmlentities() to convert these characters into HTML characters which will be displayed through the browser, would be the recommended way to make that happen.

Lucanos
+1 for htmlentities
knittl
I was looking at Google Chrome source, which apparently is the only browser to show the wrong source. So this would be a Chrome issue of not actually displaying the correct source.Originally encountered when making RSS feeds with <content:encoded> tags which contain CDATA sections in which an extraneous > appears in Chrome source. <?php echo "<item><content:encoded><![CDATA[<div>content</div>]]> </content:encoded></item>"; ?>If it is a Chrome issue then I guess the problem is solved.
mkeblx
+1  A: 

if you give it a "Content-Type: text/plain" header, chrome should render it normally.

it's possible you are either sending a "text/html" header or not sending a Content-Type header at all, so the browser must guess what kind of content it is.

lunixbochs