Home Php Input - Output String Functions
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Input - Output String Functions

Advertisement
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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 19, 2009

Related Tutorials

Ask Questions?    Discuss: Input - Output String Functions  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com