PHP Base64 Encoding Example
1 minsBase64 encoding is a binary-to-text encoding scheme that encodes binary data to a printable ASCII string format.
Many transmission media and protocols do not understand and handle binary data correctly. Base64 encoding is used to prevent binary data from being modified while in transit through such media channels.
This article teaches you how to perform Base64 encoding in PHP.
PHP Base64 encode
You can use the base64_encode()
function in PHP to perform Base64 encoding -
base64_encode ( string $data ) : string
The function takes a string as input and returns the encoded data. Here is an example -
<?php
$str = 'Hello World 😊';
echo base64_encode($str);
?>
# Output
SGVsbG8gV29ybGQg8J+Yig==
Also Read: PHP Base64 Decode Example