According to php.net
To specify a literal single quote, escape it with a backslash (\).
It means you could have:
<?php
echo '<span onclick="$(this).addClass(\'selected\');"> </span>';
?>
More Related Contents:
- Dollar ($) sign in password string treated as variable
- Single quotes or double quotes for variable concatenation? [closed]
- How to handle double quotes in string before XPath evaluation?
- Escape string to use in mail()
- Do I need to escape backslashes in PHP?
- Pass a PHP string to a JavaScript variable (and escape newlines) [duplicate]
- How can I get a hex dump of a string in PHP?
- Is there a PHP function that can escape regex patterns before they are applied?
- Remove new lines from string and replace with one empty space
- PHP, get file name without file extension
- URL Friendly Username in PHP?
- PHP: Split string [duplicate]
- Mixing a PHP variable with a string literal
- How to mimic Stack Overflow Auto-Link Behavior
- Escaping single quote in PHP when inserting into MySQL [duplicate]
- how to replace special characters with the ones they’re based on in PHP?
- How can I truncate a string to the first 20 words in PHP?
- Remove control characters from PHP string
- Convert flat array to a delimited string to be saved in the database
- Split string by new line characters
- string sanitizer for filename
- How to split a long string without breaking words?
- PHP String to Float
- How to convert a string to JSON object in PHP
- Get the first letter of each word in a string
- PHP variable interpolation vs concatenation [duplicate]
- How to Convert Boolean to String
- Delete first 3 characters and last 3 characters from String PHP
- How can I get the last 7 characters of a PHP string?
- How to convert all characters to their html entity equivalent using PHP