Home  >  Article  >  Backend Development  >  PHP url encoding and decoding (encryption/decryption)

PHP url encoding and decoding (encryption/decryption)

WBOY
WBOYOriginal
2016-07-25 08:55:461055browse
  1. function base64_url_encode($input) {
  2. return rtrim(strtr(base64_encode($input), '+/', '-'), '=');
  3. }
  4. $code_urlfile = 'test1/test2/1234';
  5. echo base64_url_encode($code_urlfile);
  6. echo '
    '; // bbs.it-home.org
  7. $url = base64_url_encode($code_urlfile);
  8. echo base64_decode($url);
  9. ?>
复制代码

结果:

dGVzdDEvdGVzdDIvMTIzNA test1/test2/1234


Statement:
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