What could I use in php in place of the normal ' and " symbols around something?
Example:
echo("Hello World!")
Thanks!
What could I use in php in place of the normal ' and " symbols around something?
Example:
echo("Hello World!")
Thanks!
There are 4 ways to encapsulate strings, single quotes
'
, double quotes"
, heredoc and nowdoc.Read the full php.net article here.
Heredoc
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
Nowdoc
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc
Escaping
If you want to use literal single or double quotes within single or double quoted strings, you have to escape them:
As Herbert noted, you don't have to escape single quotes within a double quoted strings and you don't have to escape double quotes within a single quoted string.
If you have to add quotes on a large scale, use the addslashes() function: