RE: [PHP] Trouble wirh < in a string

From: Date: Fri, 11 Oct 2002 17:25:11 +0000
Subject: RE: [PHP] Trouble wirh < in a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119673@lists.php.net to get a copy of this message
> I have a small problem a string I have for example : $myvar= "hell<o my > friend"; > When I display the content of $myvar with echo I see "hell" and not the > rest. > > I suppose the problem come from the < how solve the problem ? You're putting that string in HTML and it's being evaluated by the browser. It sees the < as the beginning of a tag, so it's looking for a tag to follow. Tags that the browser doesn't recognize are just not shown. Try to put <foo> in your HTML and it won't show up (may depend on browser). What you want to do is use an HTML entity for the <, > and other characters. < would be &lt;, > is &gt;. You can also use the htmlentities() or htmlspecialchars() function in PHP to do the conversion for you automatically. ---John Holmes...

« previous php.general (#119673) next »