In-depth analysis of PHP rawurlencode and urlencode functions_PHP tutorial

WBOY
Release: 2016-07-21 15:07:35
Original
1480 people have browsed it

Question: Both functions are designed to escape strings to make them suitable for file names. Which one to use? Which one is more standard?

Conclusion:
rawurlencode complies with the 1994 International Standard Memorandum RFC 1738.
urlencode implements the traditional approach. The main difference from the above is the use of spaces. The escape is '+' instead of '%20'
javascript's encodeURL is also the 1994 standard,

The escape of javascript is another way to mark unicode encoding with "%xxx".

It is recommended to use rawurlencode in PHP. Deprecated urlencode

Sample
source:

Super invincible person sadha sajdh data sample sdls fhejrthcxzb.file.jpeg

PHP urlencode:
%E8%B6%85%E7%BA%A7%E6%97%A0%E6%95%8C%E7%9A%84%E4%BA% BAsadha+sajdh%E6%95%B0%E6%8D%AE%E6%A0%B7%E6%9C%ACsdls+fhejrthcxzb.file.jpeg

PHP rawurlencode:
%E8%B6%85%E7%BA%A7%E6%97%A0%E6%95%8C%E7%9A%84%E4%BA% BAsadha%20sajdh%E6%95%B0%E6%8D%AE%E6%A0%B7%E6%9C%ACsdls%20fhejrthcxzb.file.jpeg

Javascript encodeURI:
%E8%B6%85%E7%BA%A7%E6%97%A0%E6%95%8C%E7%9A%84%E4%BA% BAsadha%20sajdh%E6%95%B0%E6%8D%AE%E6%A0%B7%E6%9C%ACsdls%20fhejrthcxzb.file.jpeg

Javascript escape:
%u8D85%u7EA7%u65E0%u654C%u7684%u4EBAsadha%20sajdh%u6570%u636E%u6837%u672Csdls%20fhejrthcxzb.file.jpeg

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327543.htmlTechArticleQuestion: Both functions are designed to escape strings to make them suitable for file names. Which one to use? Which one is more standard? Conclusion: rawurlencode complies with the international standard memorandum RFC 1738 of 1994, urlenco...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template