How can I use a '
and a "
in a php string?
I can't use one of them because I have used both in my website code and I think it's better and easier if I make a class for the website that than just echo everything.
Asked
Active
Viewed 67 times
0
-
3possible duplicate of [Escaping quotation marks in PHP](http://stackoverflow.com/questions/7999148/escaping-quotation-marks-in-php) – takendarkk Apr 20 '14 at 23:51
1 Answers
4
first of all you can escape then "this is \" and ' in a string"
or you can use HEREDOC instead
$string = <<<STR
this is a "string" with 'signs' and {$some_var} if needed
STR;
Note this rules though:
1. The choose of STR
was arbitrary and you can use any phrase you would like (no spaces).
2. The row with the STR;
must contain NOTHING but it (not even spaces after)

Yaron U.
- 7,681
- 3
- 31
- 45