像这样使用反斜杠
"From time to "time"";
在PHP中,反斜杠用于转义引号内的特殊字符。由于PHP不能区分字符串和字符,因此您也可以使用
'From time to "time"';
单引号和双引号之间的区别在于,双引号允许对字符串进行插值,这意味着您可以在字符串中内联引用变量,并且它们的值将像在字符串中那样进行求值
$name = 'Chris';$greeting = "Hello my name is $name"; //equals "Hello my name is Chris"
根据您对问题的最后一次修改,我认为您可能能够做到的最简单的事情是使用“
heredoc”。它们并不常用,老实说,我通常不会推荐它,但是如果您想要一种快速的方法将文本墙放入单个字符串中,则不推荐使用。可以在以下位置找到语法:http
:
//www.php.net/manual/zh/language.types.string.php#language.types.string.syntax.heredoc,下面是一个示例:
$someVar = "hello";$someOtherVar = "goodbye";$heredoc = <<<termThis is a long line of text that include variables such as $someVarand additionally some other variable $someOtherVar. It also supports having'single quotes' and "double quotes" without terminating the string itself.heredocs have additional functionality that most likely falls outsidethe scope of what you aim to accomplish.term;



