Your Ad Here
0

How To Protect Special Characters in Query String?

Posted by The Blogger on 12:12 PM in
Answer:

If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function. The script below shows how to use urlencode():

<?php
print(”<html>”);
print(”<p>Please click the links below”
.” to submit comments about FYICenter.com:</p>”);
$comment = ‘I want to say: “It\’s a good site! :->”‘;
$comment = urlencode($comment);
print(”<p>”
.”<a href=\”processing_forms.php?name=Guest&comment=$comment\”>”
.”It’s an excellent site!</a></p>”);
$comment = ‘This visitor said: “It\’s an average site! :-( ”‘;
$comment = urlencode($comment);
print(”<p>”
.’<a href=”processing_forms.php?’.$comment.’”>’
.”It’s an average site.</a></p>”);
print(”</html>”);
?>


tags: php interview questions and answers, php interview question How To Protect Special Characters in Query String, How To Protect Special Characters in Query String,special characters in php, special characters

0 Comments

Post a Comment

Your Ad Here

Copyright © 2009 Interview Questions and Answers