Php Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Question No  (1 of 137)
 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9 Last
 
Question:-
Is it possible to protect special characters in a query string?
 
Answer:-

urlencode function and rawurlencode are mostly based on RFC 1738.

However, since 2005 the current RFC in use for URIs standard is RFC 3986.

Here is a function to encode URLs according to RFC 3986.

<?php
function myUrlEncode($string) {
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
    $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
    return str_replace($entities, $replacements, urlencode($string));
}
?>

Yes, we use the urlencode() function to be able to protect special characters.

Prev   
 
 
 
image
Anil  Bist

Skills    Php

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (5)

Ask 
image
shubham
Ask 
Monika
Ask 
Anamika
Ask 
Riya
Ask 
image
Pooja
 
 

Recommended Classes

image Anil Bist
I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore an...
Professional
image shweta Pandey
Passionate about LIFE and Learning. Lets explore together better version of "self", &qu...
Professional
image shweta Pandey
Passionate about LIFE and Learning. Lets explore together better version of "self", &qu...
Professional