[posted and mailed]
[EMAIL PROTECTED] (Jtjohnston) wrote in
[EMAIL PROTECTED]:">news:[EMAIL PROTECTED]:
> This is the input of a <textarea>. I don't suppose there is an easier
> way of doing this?
> $mydata->KW = str_replace("\r", "", $mydata->KW);
> $mydata->KW = str_replace("\n", "<br>", $mydata->KW);
> $mydata->KW = str_replace("<br><br>", "<p>", $mydata->KW);
> What does htmlspecialchars do exactly?
> Yes I've read the docs, but didn't really follow.
> An email post & reply would be real helpful :)
Why not use nl2br() to modify the end of line characters? And there is
probably no value, apart from saving characters in your source, to
translate a pair of <BR> to <P>. In fact, it might have unexpected effects
if you hapen to display the output inside of a closed <P> block. So,
$mydata->KW = nl2br($mydata->KW);
Depending on how this data is being used, you might prefer to do the
translation before display rather than storing html in your database. For
instance, if the data is to be edited, embedded html may be confusing,
depending on the level of knowledge of the person editing.
In respect of htmlspecialchars, recall that symbols like < and> have
special functions in html - they signal the start and end of html tags. So
if you actually want to use a < or > in your text, you should use the
special symbol > (note the special use of the ampersand here!)
htmlspecialchars will perform the translations for you.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]