PHP code example of oire / base64
1. Go to this page and download the library: Download oire/base64 library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oire / base64 example snippets
use Oire\Base64\Base64;
use Oire\Base64\Exception\Base64Exception;
$text = "The quick brown fox jumps over the lazy dog";
$encoded = Base64::encode($text);
echo $encoded.PHP_EOL;
$encoded = Base64::encode($text, true);
echo $encoded.PHP_EOL;
$encoded = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw";
try {
$decoded = Base64::decode($encoded);
} catch(Base64Exception $e) {
// Handle errors
}
echo $decoded.PHP_EOL;