PHP's Rawurlencode and UrlEncode functions

Source: Internet
Author: User
Tags urlencode
PHP's Rawurlencode and UrlEncode functions

Problem: 2 functions are for string escaping so that they are suitable for file names. Which one should I use? Which is more standard?

Conclusion:
Rawurlencode Compliance is the 94 international standard memo RFC 1738,
UrlEncode is the traditional approach, and the main difference is that the escape from the space is ' + ' instead of '%20 '
JavaScript's encodeURI is also the 94 standard,

The escape of JavaScript is another way to mark Unicode encoding with "%xxx".

Recommended for use with Rawurlencode in PHP. Discard UrlEncode

Note: PHP rawurlencode! = JS encodeURI

?

Sample Example
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:

"%b3%ac%bc%b6%ce%de%b5%d0%b5%c4%c8%cbsadha%20sajdh%ca%fd%be%dd%d1%f9%b1%besdls%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

?

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.