Horje
PHP imap_base64() Function

The imap_base64() function is an inbuilt function in PHP that is used to decode the base64 encoded text.

Syntax:

imap_base64(string $string)

Parameters: This function accepts only one parameter which is described below.

  • $string: This is the base64 string parameter that is going to be decoded.

Return Values: The imap_base64() function returns the decoded string if this function successfully executes otherwise this function will return “false”.

Program 1: The following program demonstrates the imap_base64() function.

Note: Before using this function, check if this function is available in your environment or not. If not then type this command

apt-get install php-imap

 

For installation, please refer to the following also.

Program 1:

PHP

<?php
$string = "RGVjb2RlIHRoaXMgc2ltcGxlIHN0cmluZw==";
$decodestring = imap_base64($string);
echo "Decoded Data: $decodestring" . PHP_EOL;
?>

Output:

Decoded Data: Decode this simple string

Program 2: The following program demonstrates the imap_base64() function.

PHP

<?php
  
$string = "RGVjb2RlIHRoaXMgc2ltcGxlIHN0cmluZw==";
$string2 = "aGV5IGJ1ZGR5IAo=";
  
if (imap_base64($string) == imap_base64($string2)) {
    echo "Both strings are equal";
} else {
    echo "Both strings are not equal";
}
  
?>

Output:

Both strings are not equal                                                                                                                                                                      

Reference: https://www.php.net/manual/en/function.imap-base64.php




Reffered: https://www.geeksforgeeks.org


PHP

Related
PHP finfo_close() Function PHP finfo_close() Function
PHP finfo_set_flags() Function PHP finfo_set_flags() Function
PHP ob_get_contents() Function PHP ob_get_contents() Function
PHP SplFileObject fpassthru() Function PHP SplFileObject fpassthru() Function
PHP SplFileObject fseek() Function PHP SplFileObject fseek() Function

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
14