PHP imap_binary() Function Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The imap_binary() function is an inbuilt function in PHP that is used to convert the 8-bit string into the base64 encoding. This function is used by some IMAP servers to represent mailbox names that contain non-ASCII characters or certain ASCII characters that are special in IMAP. Syntax: imap_binary(string $string) : string | falseParameters: This function accepts only one parameter which is described below. $string: This is the string parameter that contains the 8-bit string.Return Values: The imap_binary() function if successfully executed will return a base64 encoded string otherwise this function will return "false". Note: Before using this function check if this is available in your environment or not. If not, then type this command apt-get install php-imapReferences: How to Install imap extension in PHP on Windows?How to Install imap extension in PHP on Linux? Program 1: The following program demonstrates the imap_binary() function. PHP <?php $string = "geeksforgeeks"; $eightBitData = imap_binary($string); // Output the result echo "Original data: $string\n"; echo "Converted base64 data: $eightBitData\n"; ?> Output: Original data: geeksforgeeksConverted base64 data: Z2Vla3Nmb3JnZWVrcw==Program 2: The following program demonstrates the imap_binary() function. PHP <?php $utf7data1 = "&ZeVnLIqe-"; $utf7data2 = "&BfAEEAbABlAG4ALwA-"; // Check if the imap_binary() function exists if (function_exists("imap_binary")) { $eightBitData1 = imap_binary($utf7data1); $eightBitData2 = imap_binary($utf7data2); // Output the results echo "Original UTF-7 data 1: $utf7data1\n"; echo "Converted 8-bit data 1: $eightBitData1\n\n"; echo "Original UTF-7 data 2: $utf7data2\n"; echo "Converted 8-bit data 2: $eightBitData2\n"; } else { echo "imap_binary() function is not available" . " in this environment.\n"; } ?> Output: Original UTF-7 data 1: &ZeVnLIqe-Converted 8-bit data 1: JlplVm5MSXFlLQ==Original UTF-7 data 2: &BfAEEAbABlAG4ALwA-Converted 8-bit data 2: JkJmQUVFQWJBQmxBRzRBTHdBLQ==Reference: https://www.php.net/manual/en/function.imap-binary.php Comment More infoAdvertise with us Next Article PHP | gmp_clrbit() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-IMAP Similar Reads 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 V 1 min read PHP | hash_final() Function The hash_final() function is an inbuilt function in PHP which is used to finalize an incremental hash and return the resulting digest. Syntax: hash_final( $context, $raw_output ) Parameters: This function accept two parameters as mention above and describe below. $context: This parameter is used to 1 min read PHP | hash_final() Function The hash_final() function is an inbuilt function in PHP which is used to finalize an incremental hash and return the resulting digest. Syntax: hash_final( $context, $raw_output ) Parameters: This function accept two parameters as mention above and describe below. $context: This parameter is used to 1 min read PHP | gmp_clrbit() Function The gmp_clrbit() function is an in-built function in PHP which clears a bit of a GMP number (GNU Multiple Precision). The gmp_clrbit() function sets the bit at a specified index in a GMP number to 0. The index starts at zero from the least significant bit. Syntax : gmp_clrbit( $num, $index ) Paramet 2 min read PHP | gmp_clrbit() Function The gmp_clrbit() function is an in-built function in PHP which clears a bit of a GMP number (GNU Multiple Precision). The gmp_clrbit() function sets the bit at a specified index in a GMP number to 0. The index starts at zero from the least significant bit. Syntax : gmp_clrbit( $num, $index ) Paramet 2 min read PHP decbin( ) Function While working with numbers, many times we need to convert the bases of number and one of the most frequent used conversion is decimal to binary conversion. PHP provides us with a built-in function, decbin() for this purpose.The decbin() function in PHP is used to return a string containing a binary 1 min read Like