在PHP字符串中使用'和'[关闭]

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.

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)