Skip to content

Instantly share code, notes, and snippets.

@imZack
Created May 12, 2013 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imZack/5562864 to your computer and use it in GitHub Desktop.
Save imZack/5562864 to your computer and use it in GitHub Desktop.
<?php
function encodeURI($url) {
// http://php.net/manual/en/function.rawurlencode.php
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI
$unescaped = array(
'%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~',
'%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')'
);
$reserved = array(
'%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':',
'%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$'
);
$score = array(
'%23'=>'#'
);
return strtr(rawurlencode($url), array_merge($reserved,$unescaped,$score));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment