PHP quoted_printable_decode() Function

What is PHP quoted_printable_decode() Function?

If you want to convert a “quoted-printable encoded string” back to its 8-bit ASCII string, use quoted_printable_decode() function.

What is a “quoted printable encoded string”?

A quoted printable encoded string is a text string of an 8-bit ASCII string which is produced from a 7-bit string using “quoted printable” encoding method.

“Quoted printable” encoding is mainly used in email system (MIME) to send characters that are added by 8-bit extended ASCII characters.

Example of “quoted printable encoded string”

All the 7-bit ASCII characters remain unchanged. But, each special character from 8-bit are encoded by added equal sign (=) in front of the hexadecimal value of that character. So, “Quoted printable encoded string” of equal sign (=) is =3D, “Quoted printable encoded string” of € is =e2=82=ac etc.

Syntax:

quoted_printable_decode(string)

Parameters:

The Function has 1 required parameter-

string (Required): The quoted-printable encoded string.

Return Values:

The function returns the decoded string.

Examples:

Example 1:

<?php
$str = "Price is =E2=82=AC20";
echo quoted_printable_decode($str);
?>

Output:

Price is €20

Notes on quoted_printable_decode() Function:

  • When the function converts, it follows the rules defined in RFC2045, section 6.7.
  • You can’t decode a quoted-printable text in email headers. For this, you need to use iconv_mime_decode() function.

PHP Version Support:

PHP 4, PHP 5, PHP 7, PHP 8

Summary: PHP quoted_printable_decode() Function

quoted_printable_decode() function is one of the built-in string function. Use this function to decode an encoded quoted printable string to its original form.

Reference:

https://www.php.net/manual/en/function.quoted-printable-decode.php