Friday, November 21, 2025
HomeLanguagesPHP | base64_decode() Function

PHP | base64_decode() Function

The base64_decode() is an inbuilt function in PHP which is used to Decodes data which is encoded in MIME base64.
Syntax: 
 

string base64_decode( $data, $strict )

Parameters: This function accepts two parameter as mentioned above and described below: 
 

  • $data: It is mandatory parameter which contains the encoded string.
  • $strict: It is an optional parameter. If this parameter is set to TRUE then the base64_decode() function will return FALSE if the input contains character from outside the base64 alphabet. Invalid characters will be silently discarded.

Return value: This function returns the decoded string on success or returns False in case of failure.
Below programs illustrate the base64_decode() function in PHP:
Program 1: 
 

php




<?php
 
// Program to illustrate base64_decode()
// function
$str = 'R2Vla3Nmb3JHZWVrcw==';
 
echo base64_decode($str);
?>


Output: 

neveropen

 

Program 2: 
 

php




<?php
 
// Program to illustrate base64_decode()
// function
$str = 'R0ZHLCBBIGNvbXB1dGVyIFNjaWVuY2UgUG9ydGFsIEZvciBHZWVrcw';
echo base64_decode($str). "\n";
 
$str = 'MQ==';
echo base64_decode($str). "\n";
?>


Output: 

GFG, A computer Science Portal For Geeks
1

 

Reference: http://php.net/manual/en/function.base64-decode.php
 

RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11997 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS