php base64_encode() – How to Use Base64 Encoding in PHP?

php base64_encode Examples : The base64_encode() function in PHP encodes data with MIME base64. base64 encoded data consumes 33% more space. Means encoded data is 33% larger than original data.

php base64_encode

There are the following the list of “php base64 encode”.

php base64_encode – Supported Versions:

  • PHP 4
  • PHP 5
  • PHP 7

PHP base64_encode() Syntax

base64_encode ( string $string )

string $string | required : string value to be encoded.
Return Value : base64 encoded string return करता है।

PHP base64_encode() Example


The base64_decode() function is used to decode a base64 encoded string.

How to convert an image to Base64 encoding?

$path = 'rajkot/loveshop.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);


base64_encode ( string $string ) : string


base64_decode ( string $string , bool $strict = false ) : string|false

@ref :

store the result in a variable and check for errors


Leave a Comment