PHPMailer\PHPMailer

PHPMailer::quotedString()public staticWP 1.0

If a string contains any "special" characters, double-quote the name, and escape any double quotes with a backslash.

Method of the class: PHPMailer{}

No Hooks.

Return

String.

Usage

$result = PHPMailer::quotedString( $str );
$str(string) (required)
-

Notes

  • See: RFC822 3.4.1

PHPMailer::quotedString() code WP 6.4.1

public static function quotedString($str)
{
    if (preg_match('/[ ()<>@,;:"\/\[\]?=]/', $str)) {
        //If the string contains any of these chars, it must be double-quoted
        //and any double quotes must be escaped with a backslash
        return '"' . str_replace('"', '\\"', $str) . '"';
    }

    //Return the string untouched, it doesn't need quoting
    return $str;
}