Input - Output String Functions
This tutorial is showing some functions that
you need to use for your taking data from a user (text field, text area) since
it is not secure to receive a string data and input them directly into your
database.
Some special characters as ", ' , \ may be stop your SQL commands or damage
your database structure and as the gateway for hackers to hack your website.
Returns a string with backslashes before characters that need to be quoted in
database queries etc.
Example:
<?php
$str="rose'india";
echo "Actual string is:".$str;
echo"<br/> After adding slash it become:".addslashes($str);
echo"<br/>We can break line as follows:".nl2br("This is the \n 14th day of November");
echo"<br/>After removing the slash the sting we will become<br/>";
echo stripslashes($str);
?>
Output:
Actual string is:rose'india
After adding slash it become:rose\'india
We can break line as follows:This is the
14th day of November
After removing the slash the sting we will become
rose'india