Home Php Input - Output String Functions



Input - Output String Functions
Posted on: November 19, 2009 at 12:00 AM
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.

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

Related Tags for Input - Output String Functions:


More Tutorials from this section

Ask Questions?    Discuss: Input - Output String Functions  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.