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:

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

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

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 (1)

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.
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.