Re: [PHP] string concat with < and > From: Matt McClanahan (cardinal <email protected>)
Date: 09/30/00

On Sat, 30 Sep 2000, Remco Chang wrote:

> i'm having trouble concatenating strings with the characters '<' and '>'.
>
> $msg = "hello";
> $msg = "<".$msg.">";
>
> this doesn't work at all... i would like $msg to be <hello>, but i end up
> getting an empty string.
>
> neither does "<<".$msg.">>" or "\<".$msg."\>" work...
>
> i'm stumped, any ideas?

Works fine. But if you echo that to a browser, it'll parse <hello> as a
tag and display nothing. (Hint: Viewing the html source when debugging is
almost always useful)

If you want to display '<hello>' in a browser, you'd need to use &lt; and
&gt; instead of < and >.

$msg = 'hello';
$msg = "&lt;$msg&gt;";

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>