Testing URL Encoding and Decoding Variables

Conclusions:

Setting variables:

$v_title = "The title has an apostrophe's, 2  \slashes\, an @ sign, a plus +, a tildy ~, "double quotes" and an & ampersand in it.";
$v_rp = "http://www.mentalshots.com/_tests/test_urlencode_variables.php";
$v_rt = $v_title;
$v_rp2 = urlencode($v_rp);
$v_rt2 = urlencode($v_rt);
$v_rp3 = urlencode(htmlentities($v_rp));
$v_rt3 = urlencode(htmlentities($v_rt));

$_SESSION['s_rp'] = $v_rp;
$_SESSION['s_rt'] = $v_rt;
$_SESSION['s_rp2'] = $v_rp2;
$_SESSION['s_rt2'] = $v_rt2;
$_SESSION['s_rp3'] = $v_rp3;
$_SESSION['s_rt3'] = $v_rt3;

// Set cookie sessions
$v_expire = time()+3600*24*365;
setcookie ('c_rp', $v_rp, $v_expire, '/'); 
setcookie ('c_rt', $v_rt, $v_expire, '/'); 
setcookie ('c_rp2', $v_rp2, $v_expire, '/'); 
setcookie ('c_rt2', $v_rt2, $v_expire, '/'); 
setcookie ('c_rp3', $v_rp3, $v_expire, '/'); 
setcookie ('c_rt3', $v_rt3, $v_expire, '/'); 

Link to test_urlencode_variables.php

Get Link for rp=http://www.mentalshots.com/_tests/test_urlencode_variables.php&rt=The title has an apostrophe's, 2 \slashes\, an @ sign, a plus +, a tildy ~, "double quotes" and an & ampersand in it.

Get Link for rp2=http%3A%2F%2Fwww.mentalshots.com%2F_tests%2Ftest_urlencode_variables.php&rt2=The+title+has+an+apostrophe%27s%2C+2++%5Cslashes%5C%2C+an+%40+sign%2C+a+plus+%2B%2C+a+tildy+%7E%2C+%22double+quotes%22+and+an+%26+ampersand+in+it.

Get Link for rp3=http%3A%2F%2Fwww.mentalshots.com%2F_tests%2Ftest_urlencode_variables.php&rt3=The+title+has+an+apostrophe%26%23039%3Bs%2C+2++%5Cslashes%5C%2C+an+%40+sign%2C+a+plus+%2B%2C+a+tildy+%7E%2C+%26quot%3Bdouble+quotes%26quot%3B+and+an+%26amp%3B+ampersand+in+it.

SESSIONS

Unencoded Form

$_SESSION[s_rp] = http://www.mentalshots.com/_tests/test_urlencode_variables.php

$_SESSION[s_rt] = The title has an apostrophe's, 2 \slashes\, an @ sign, a plus +, a tildy ~, "double quotes" and an & ampersand in it.

Url Encoded Form

$_SESSION[s_rp2] = http%3A%2F%2Fwww.mentalshots.com%2F_tests%2Ftest_urlencode_variables.php

$_SESSION[s_rt2] = The+title+has+an+apostrophe%27s%2C+2++%5Cslashes%5C%2C+an+%40+sign%2C+a+plus+%2B%2C+a+tildy+%7E%2C+%22double+quotes%22+and+an+%26+ampersand+in+it.

Encoded Form

$_SESSION[s_rp3] = http%3A%2F%2Fwww.mentalshots.com%2F_tests%2Ftest_urlencode_variables.php

$_SESSION[s_rt3] = The+title+has+an+apostrophe%26%23039%3Bs%2C+2++%5Cslashes%5C%2C+an+%40+sign%2C+a+plus+%2B%2C+a+tildy+%7E%2C+%26quot%3Bdouble+quotes%26quot%3B+and+an+%26amp%3B+ampersand+in+it.

Url Decoded

$_SESSION[s_rp2] decoded = http://www.mentalshots.com/_tests/test_urlencode_variables.php

$_SESSION[s_rt2] decoded = The title has an apostrophe's, 2 \slashes\, an @ sign, a plus +, a tildy ~, "double quotes" and an & ampersand in it.

Html Decoded and then Url Decoded

$_SESSION[s_rp3] decoded = http://www.mentalshots.com/_tests/test_urlencode_variables.php

$_SESSION[s_rt3] decoded = The title has an apostrophe's, 2 \slashes\, an @ sign, a plus +, a tildy ~, "double quotes" and an & ampersand in it.

POST

Unencoded Form

$_POST[f_rp] =

$_POST[f_rt] =

Url Encoded Form

$_POST[f_rp2] =

$_POST[f_rt2] =

Url and Html Encoded Form

$_POST[f_rp3] =

$_POST[f_rt3] =

Url Decoded

$_POST[f_rp2] decoded =

$_POST[f_rt2] decoded =

Html Decoded and then Url Decoded

$_POST[f_rp3] decoded =

$_POST[f_rt3] decoded =

GET

Unencoded Form

$_GET[rp] =

$_GET[rt] =

Url Encoded Form

$_GET[rp2] =

$_GET[rt2] =

Url and Html Encoded Form

$_GET[rp3] =

$_GET[rt3] =

Url Decoded

$_GET[rp2] decoded =

$_GET[rt2] decoded =

Html Decoded and then Url Decoded

$_GET[rp3] decoded =

$_GET[rt3] decoded =

COOKIE

Unencoded Form

$_COOKIE[c_rp] =

$_COOKIE[c_rt] =

Url Encoded Form

$_COOKIE[c_rp2] =

$_COOKIE[c_rt2] =

Url and Html Encoded Form

$_COOKIE[c_rp3] =

$_COOKIE[c_rt3] =

Url Decoded

$_COOKIE[c_rp2] decoded =

$_COOKIE[c_rt2] decoded =

Html Decoded and then Url Decoded

$_COOKIE[c_rp3] =

$_COOKIE[c_rt3] =

Now print all variables using Print_r ($_SESSION)

Array ( [s_rp] => http://www.mentalshots.com/_tests/test_urlencode_variables.php [s_rt] => The title has an apostrophe's, 2 \slashes\, an @ sign, a plus +, a tildy ~, "double quotes" and an & ampersand in it. [s_rp2] => http%3A%2F%2Fwww.mentalshots.com%2F_tests%2Ftest_urlencode_variables.php [s_rt2] => The+title+has+an+apostrophe%27s%2C+2++%5Cslashes%5C%2C+an+%40+sign%2C+a+plus+%2B%2C+a+tildy+%7E%2C+%22double+quotes%22+and+an+%26+ampersand+in+it. [s_rp3] => http%3A%2F%2Fwww.mentalshots.com%2F_tests%2Ftest_urlencode_variables.php [s_rt3] => The+title+has+an+apostrophe%26%23039%3Bs%2C+2++%5Cslashes%5C%2C+an+%40+sign%2C+a+plus+%2B%2C+a+tildy+%7E%2C+%26quot%3Bdouble+quotes%26quot%3B+and+an+%26amp%3B+ampersand+in+it. )

Return to Test Directory Home Page