Encode the string to or decode from a base64 encoded value.

Twine\Str::base64( [ string $mode = Twine\Config\Base64::ENCODE ] ) : Twine\Str

Parameters

$mode A base64 mode flag

Available base64 modes:

Twine\Config\Base64::ENCODE Encode the string to base64
Twine\Config\Base64::DECODE Decode the string from base64

Examples

$string = new Twine\Str('john pinkerton');

        $string->base64(); // Returns 'am9obiBwaW5rZXJ0b24='
$string = new Twine\Str('am9obiBwaW5rZXJ0b24=');

        $string->base64(Twine\Config\Base64::DECODE); // Returns 'john pinkerton'
$string = new Twine\Str('john pinkerton');

        $string->base64Encode(); // Returns 'am9obiBwaW5rZXJ0b24='
$string = new Twine\Str('am9obiBwaW5rZXJ0b24=');

        $string->base64Decode(); // Returns 'john pinkerton'

Aliases

Twine\Str::base64Encode() = Twine\Str::base64(Twine\Config\Base64::ENCODE)
Twine\Str::base64Decode() = Twine\Str::base64(Twine\Config\Base64::DECODE)