What is PHP String Escape Tool?
PHP single-quoted strings have a deliberately small set of escape sequences: a backslash and a single quote must be escaped. This tool prepares a literal representation of text for examples and source-code generation. It does not make text safe for SQL, HTML, JavaScript, shell commands, or other contexts.
What can you use it for?
- Create a PHP string literal for a code example or configuration snippet.
- Escape apostrophes and backslashes before placing sample text in PHP source code.
- Compare the original text with the generated PHP representation.
How to use this tool
- Paste the text you want to represent in PHP.
- Select Escape as PHP single-quoted string.
- Review the generated literal, including its surrounding single quotes.
- Copy the output and review it in the context of your PHP source code.
Example input
Load this text to see how an apostrophes and backslashes are represented in a PHP single-quoted string.
It's PHP\tools!
Tips and things to know
- In PHP single-quoted strings, a backslash and an apostrophe are the only special escape cases.
- This is source-code escaping, not output escaping or input sanitization.
- Use PDO prepared statements for SQL values; never build SQL by concatenating escaped strings.
- For HTML output, use htmlspecialchars() with the correct flags and encoding.
Frequently asked questions
Does this protect a string for SQL?
No. Use parameterized queries with PDO. PHP string escaping is unrelated to SQL injection prevention.
Does it escape double quotes?
Double quotes do not need escaping inside a PHP single-quoted string.
Does it execute PHP?
No. The browser creates a PHP code snippet as text; no PHP code is executed.