YouTip LogoYouTip

Pdo Quote

# PDO::quote [![Image 3: PHP PDO Reference](#)PHP PDO Reference](#) PDO::quote β€” Quotes a string for use in a SQL statement. (PHP 5 >= 5.1.0, PECL pdo >= 0.2.1) * * * ## Description ### Syntax public string PDO::quote ( string $string [, int $parameter_type = PDO::PARAM_STR ] ) PDO::quote() quotes a string for use in a SQL statement, or escapes special strings. * * * ## Parameters **string** The string to be quoted. **parameter_type** Provides the data type for the driver. * * * ## Return Values Returns a quoted string that theoretically can be safely passed to an SQL statement. Returns FALSE if the driver does not support quoting. * * * ## Examples ### Quoting a plain string quote($string) . "n";?> The above example will output: Unquoted string: NiceQuoted string: 'Nice' ### Escaping a special string quote($string) . "n";?> The above example will output: Unquoted string: Naughty ' string Quoted string: 'Naughty '' string' [![Image 4: PHP PDO Reference](#)PHP PDO Reference](#)
← Pdo RollbackPdo Query β†’