Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa PHP How To Protect Special Characters in Query String?

Have Programming Question? Ask it here!
 
 
 


brijesh
How To Protect Special Characters in Query String?
1 Answer(s)      3 years and 9 months ago
Posted in : PHP


How To Protect Special Characters in Query String?


Advertisement
View Answers

November 15, 2010 at 1:00 PM


Hi all,

For this purpose you can urlencode() translation function.

Example :

<?php

$string = "This is deepak.";

$url = "my.php?data=" . urlencode($string);
print "<a href=\"$url\">Just Click</a><br>";
if (isset($_REQUEST["data"])) {
   print "URL IS : " . $_SERVER['REQUEST_URI'] . "<br>";
   print "Decoded data is : " . urldecode($_REQUEST["data"]);
}

?>

The output :

Just Click 
URL IS : /my.php?data=This+is+deepak+.
Decoded data is : This is deepak.

Thanks



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com