PHP quoted_printable_decode() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

In PHP, quoted_printable_decode() converts a quoted-printable string back into plain 8-bit text.

Quoted-printable is a format used in email. Codes like =C3=A9 stand for special bytes.

Syntax

Call quoted_printable_decode() with the values you need. Start with this line.

PHP
$text = quoted_printable_decode("Caf=C3=A9");
CallWhat it does
quoted_printable_decode("Caf=C3=A9")Returns "Café".
quoted_printable_decode("a=3Db")Returns "a=b".
quoted_printable_decode("Hello=\r\nWorld")Returns "HelloWorld". Soft line breaks are removed.

An equals sign followed by two hex digits becomes one byte. An equals sign at the end of a line joins the lines.

Library declarations
PHP
quoted_printable_decode(string $string): string

Parameters

ParameterDescription
stringRequired. The quoted-printable string to decode.

Return Value

Return ValueDescription
stringThe decoded 8-bit string.

PHP Examples

Example 1 — Decode an Accented Word

Turn =C3=A9 back into the letter é.

PHP
<?php
$encoded = "Caf=C3=A9";

echo quoted_printable_decode($encoded), PHP_EOL;

How It Works

  1. Start with encoded text. =C3=A9 is the UTF-8 bytes of é.
  2. Call the function. Each =XX code becomes one byte.
  3. Bytes join up. They form the letter é.
  4. Print the result. You see Café.

Example 2 — Soft Line Breaks

An equals sign at the end of a line is a soft break and is removed.

PHP
<?php
$encoded = "Hello=\r\nWorld";

echo quoted_printable_decode($encoded), PHP_EOL;

How It Works

  1. Look at the input. = comes right before the line break.
  2. Soft break rule. It means the line was only wrapped for length.
  3. PHP joins the lines. The break and the equals sign disappear.
  4. Result. The two parts become one word.

Example 3 — Decode an Equals Sign

Since = is special, a real equals sign is written as =3D.

PHP
<?php
$encoded = "2 + 2 =3D 4";

echo quoted_printable_decode($encoded), PHP_EOL;

How It Works

  1. Find the code. =3D is the hex code for the equals sign.
  2. Decode it. PHP replaces it with the real character.
  3. Other text stays. Plain letters and spaces are not changed.
  4. Use it for email bodies. They often come in this form.

Frequently Asked Questions

It converts a quoted-printable string, such as one found in an email body, back into plain 8-bit text.
string quoted_printable_decode(string $string). It takes one string and returns the decoded string.
It is an encoding that writes non-ASCII bytes as an equals sign plus two hex digits, so text can travel safely through systems that only handle 7-bit data.
It is the encoded form of the equals sign itself, because the equals sign is used to start every code.
Use quoted_printable_encode(). It is the opposite of this function.

Next: quoted_printable_encode()

quoted_printable_encode() converts an 8-bit string into quoted-printable text.

quoted_printable_encode() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful