List Info

Thread: note 49689 deleted from function.addslashes by philip




note 49689 deleted from function.addslashes by philip
user name
2006-03-31 15:26:23
Note Submitter: sundevil at hexagonomistico dot com 

----

Hey! if you will use a database to store data that will only
be accessible through a web page i.e. just for web purposes,
you may use other kind of filters. I recommend to use first
the addcslashes() function, in order to escape line feeds
and then to replace those line feeds by the corresponding
html tag. And finally use the htmlentities() function in
order to replace those annoying quotes or other characters
by their corresponding html tag.
For example, data stored in a textarea as:

"hola"
<hola>
más niños

May be filtered using: addcslashes($textarea,
"\n,\\"), as:
"Hola"\n<hola>\nmás niños

Then, using: htmlentities($textarea,ENT_QUOTES), should
return:
&quot;Hola&quot;\n&lt;hola&gt;\nm&aacu
te;s ni&ntilde;os
(Which has just converted the special characters in their
html tags)

Finally, using:
str_replace('\n','<br>',$textarea), may add a
html line feed everytime it encounters a \n. So, when you
retrieve data from the database you will be able to use it
as html code just as typed!
(perhaps retrieving into a textarea gives a little more
problem! Oops!)

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )