[Solved] use of in php and in wamp


I assume it doesn’t have anything to do with WAMP, and I’m not even sure I understand the situation fully, because you say “Strings in php cant have the characters <> in them in the wamp environment” (I interpret it as: It doesn’t work with WAMP) and then directly afterwards “It all works fine in the live server. e g under wamp” (I interpret it as: It does work with WAMP).

But I believe the problem is just that you are adding stray unencoded <‘s into the HTML output. Think about what would happen normally:

<?php echo "I can write <em>emphasized</em> text!"; ?>

…would result in:

I can write emphasized text!

…and not:

I can write <em>emphasized</em> text!

Because you can output HTML from PHP, and the browser will read it as it would read any static HTML page. Now if you just include a random <, it will be interpreted as HTML as said in the comments and will not be valid.

So, in order to have a literal < shown in the browser, it has to be encoded as HTML entity, in this case &lt;, e.g. 3 &lt; 4 instead of 3 < 4. This can be automatically done using the function htmlentities. For example:

<?php echo htmlentities("This is a string with < and > and & and other stuff like this which has to be encoded."); ?>

3

solved use of <> in php and in wamp