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
="rose'india";$str
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
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Input - Output String Functions
Post your Comment