함수 encodeURI()

1 JavaScript[ | ]

console.log( encodeURI("?") );
// ?
console.log( encodeURI("http://www.Not a URL.com") );
// http://www.Not%20a%20URL.com
console.log( encodeURI('https://example.com/?x=안녕') );
// https://example.com/?x=%EC%95%88%EB%85%95

2 PHP[ | ]

function encodeURI($url) {
	return strtr(rawurlencode($url),[
		'%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!','%7E'=>'~',
		'%2A'=>'*','%27'=>"'",'%28'=>'(','%29'=>')','%3B'=>';',
		'%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':','%40'=>'@',
		'%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$','%23'=>'#']);
}
var_dump( encodeURI("?") );
var_dump( encodeURI("http://www.Not a URL.com") );
var_dump( encodeURI('https://example.com/?x=안녕') );
# string(1) "?"
# string(28) "http://www.Not%20a%20URL.com"
# string(41) "https://example.com/?x=%EC%95%88%EB%85%95"

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}