我得到這個:如何獲得多行匹配以在NOWDOC字符串上工作?
$p= <<<'EOD'
stuff
more
EOD;
print (preg_match ('~^stuff$~m', $p)); // expected 1, got 0
儘管
http://php.net/manual/en/reference.pcre.pattern.modifiers.php
的「行首」和「行結束」構建匹配立即 以下或立即在受任何換行符前字符串,分別爲
編輯:這是在一個標準的Windows文本文件。
您應該使用'/'而不是'〜'作爲模式的開始和結束。 –