-2

The title says everything, it detects the quotation marks in the HTML. How do I get it to not do this?

$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);
Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
Justin
  • 3
  • 1

3 Answers3

2

as victor says, or:

$txt = '<html><body><video width="1000" controls>
    <source src="video.mp4" type="video/mp4">
    Your browser does not support HTML5 video.
</video></body></html>';

or

$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;
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • or the third and fourth options you can find here: http://php.net/manual/en/language.types.string.php –  Dec 12 '14 at 00:16
0

You need to "escape" your quotation marks. Try the following:

$txt = "<html><body><video width="1000" controls>
    <source src=\"video.mp4\" type=\"video/mp4\">
    Your browser does not support HTML5 video.
</video></body></html>";
Victory
  • 5,811
  • 2
  • 26
  • 45
0

This is known as string escaping

$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);

Where you have opened your block with double quotes " " any attributes within must be escaped using single quotes ' ' and vice versa.

Master Yoda
  • 4,334
  • 10
  • 43
  • 77