PHP base64 encoding and decoding examples

Source: Internet
Author: User
This article mainly introduces the PHP base64 encoding and decoding instance code of the relevant information, the need for friends can refer to the following

PHP base64 encoding and decoding detailed

1. Custom rule mode encoding and decoding

Instance


Public Function Test_changinttostr () {    $intvalue 1 = 1232344234;    $intStr = ";    $str = "Y 9 L f k g y 5 R o v i x i 1 a o F 8 U H D s 3 R 4 D M p L q Z J x p q E b E 0 W s J B N 7 W v Z M n 2 G C 6 T H C A K u T ";    $seq = Explode ("", $str);    $intvalue = $intvalue 1;    while ($intvalue >=) {      # code ...      $INTSTR = ($seq [$intvalue%]). $intStr;      $intvalue = (int) ($intvalue/62);    }    $INTSTR = ($seq [$intvalue]). $intStr;    Echo ($INTSTR);    $keySeq = Array_flip ($SEQ);    $length = strlen ($INTSTR);    $value = 0;    for ($i = $length-1; $i >=0; $i-) {      $t = $keySeq [$INTSTR [$i]];        $s = ($length-$i)-1;        $m = (POW ($s) * $t);      $value + = $m;    }    echo $value;  }


2. Using System functions to complete the encoding and decoding of base64 bits

Instance code:


Public Function Testarray () {//    $str [' a '] = ' sdfsdf ';//    $str [' d '] = ' sdafsdf ';//    $NEWSTR = $this Modifyarray ($STR);    $value = Gmp_strval (Gmp_init (' 234234234234 ', ten), +);    $newValue = Gmp_strval (Gmp_init ($value, ());      }


The above is the whole content of this article, I hope that everyone's study has helped.


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.