top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How the Special characters in query string can be protected?

0 votes
383 views
How the Special characters in query string can be protected?
posted Jun 18, 2014 by Sachin Dahda

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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("

Please click the links below" ." to submit comments about xyz.com:

"); $comment = 'I want to say: "It\'s a good site! :->"'; $comment = urlencode($comment); print("

" ."" ."It's an excellent site!

"); $comment = 'This visitor said: "It\'s an average site! :-("'; $comment = urlencode($comment); print("

" .'' ."It's an average site.

"); print(""); ?>

If you copy this script as submit_comments.php to your Web server, and click the first link, you will get:
query_string = name=Guest&comment=
I+want+to+say%3A+%22It%27s+a+good+site%21+%3A-%3E%22
Number of values: 2
name = Guest
comment = I want to say: "It's a good site! :->"

If you click the second link, you will get:
query_string
= This+visitor+said%3A+%22It%27s+an+average+site%21+%3A-%28%22
Number of values: 1
This_visitor_said:_\"It\'s_an_average_site!_:-(\" =

answer Jun 18, 2014 by Karamjeet Singh
Similar Questions
0 votes

In Chrome & Firefox its working fine. Looks like in IE only 2,083 characters are allowed. Is there any way to support more characters like Chrome.

0 votes

I have program which takes special character as parameter in command line for a program in java.
But I can not send * (asterisk) as input for my program.

Give me some explain and solution for my problem.

...