0
我需要將長的多行文本放入變量中。 但有了'評論',文本的一小部分不應該在結果中。從HEREDOC中排除文字
僞代碼:
$var = <<<MULTILINETEXT
Some text {//Excluded from output}
Some text2 {//Excluded from output}
MULTILINETEXT;
是$ var在此之後:
Some text
Some text2
任何想法?
不使用HEREDOC或不使用註釋 –
您不能在HEREDOC中使用註釋。 http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc –
他可以在heredoc中使用註釋,但解釋器會將其視爲字符串而不是註釋。它會在執行後看起來像這樣一些文本{//從輸出中排除}一些text2 {//從輸出中排除} –