标题说明了一切,它检测HTML中的引号。我怎么能不这样做呢?
$html = fopen($videoname."/video.html", "w") or die("Unable to Play Video");
$txt = "<html><body><video width="1000" controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video></body></html>";
fwrite($html, $txt);
fclose($html);
答案 0 :(得分:2)
,或者:
$txt = '<html><body><video width="1000" controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video></body></html>';
或
$txt = <<<EOT
<html><body><video width="1000" controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video></body></html>
EOT;
答案 1 :(得分:0)
你需要&#34;逃避&#34;你的引号。请尝试以下方法:
$txt = "<html><body><video width="1000" controls>
<source src=\"video.mp4\" type=\"video/mp4\">
Your browser does not support HTML5 video.
</video></body></html>";
答案 2 :(得分:0)
这称为字符串转义
$html = fopen($videoname."/video.html", "w") or die("Unable to Play Video");
$txt = "<html><body><video width='1000' controls>
<source src='video.mp4' type='video/mp4'>
Your browser does not support HTML5 video.
</video></body></html>";
fwrite($html, $txt);
fclose($html);
如果您使用双引号打开块,则必须使用单引号''转义其中的任何属性,反之亦然。