rawurlencode.php
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
function mijn_rawurlencode($url) : string
{
$hex = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'
];
$buffer = '';
$lengte = strlen($url);
for ($i = 0; $i < $lengte; $i++) {
$c = $url[$i];
if ($c === ' ') {$buffer .= '+';}
elseif (($c < '0' && $c !== '-' && $c !== '.')
|| ($c > '9' && $c < 'A')
|| ($c > 'Z' && $c < 'a' && $c !== '_')
|| ($c > 'z' && $c !== '~'))
{
$c = ord($c);
$buffer .= '%' . $hex[$c >> 4] . $hex[$c & 15];
}
else {$buffer .= $c;}
}
return $buffer;
}
function mijn_rawurlencode($url) : string
{
$hex = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'
];
$buffer = '';
$lengte = strlen($url);
for ($i = 0; $i < $lengte; $i++) {
$c = $url[$i];
if ($c === ' ') {$buffer .= '+';}
elseif (($c < '0' && $c !== '-' && $c !== '.')
|| ($c > '9' && $c < 'A')
|| ($c > 'Z' && $c < 'a' && $c !== '_')
|| ($c > 'z' && $c !== '~'))
{
$c = ord($c);
$buffer .= '%' . $hex[$c >> 4] . $hex[$c & 15];
}
else {$buffer .= $c;}
}
return $buffer;
}