[개발]프로그래밍/php
[php] urldecode - URL 디코딩
좋은 블로그
2019. 12. 13. 11:41
1
urldecode() - 개념urlencode() , rawurlencode()로 URL 인코딩된 문자열을 각각 urldecode() , rawurldecode()로 디코딩 할 수 있습니다.
2
urldecode() - 예제PHP
코드
1 2 3 4 5 6 7 8 9 | <?php $test1 ="php%EC%99%80+%ED%82%A4%EB%B3%B4%EB%93%9C.html"; $test2 ="php%EC%99%80%20%ED%82%A4%EB%B3%B4%EB%93%9C.html"; echo urldecode($test1); echo "<br><br>"; echo rawurldecode($test2); ?> |
결과
화면
코드
설명
앞에서 URL을 가져올 때 공백이나 한글의 경우에는 인코딩을 해줬는데 이 인코딩된 URL을 다시 디코딩 해주고자 할 때 쓰는 것이 urldecode,rawurldecode 입니다.
urlencode으로 인코딩으로 해주었다면 urldecode로 디코딩을 하고 rawurlencode로 인코딩을 한 경우에는 rawurldecode로 디코딩을 해주시면 됩니다.