通过包含 PHP 变量嵌入视频时在 HTML 文件中出现意外结果

尝试将链接放入变量中并按如下方式调用它(作为 .html 扩展名):


<!DOCTYPE html>

        <html>

        <body>


        <h1>My first PHP page</h1>


        <?php

        $link="https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1";


        ?>


        <video controls="" height="640" width="720">

          <source src="<?php echo $link ?>" type="video/mp4"></source>

          <source src="<?php echo $link ?>" type="video/webm"></source>

          Your browser does not support the video tag.

        </video>

        </body>

        </html>

但是我在 chrome 浏览器上得到了 unexpexted 输出:

在此处输入图像描述

我也尝试使用以下代码破坏 .php 扩展名:


<?php

$link='"https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1"';


echo '<video controls="" height="640" width="720">

  <source src=', $link, 'type="video/mp4"></source>

  <source src=', $link, 'type="video/webm"></source>

  Your browser does not support the video tag.

</video>

</body>

</html>';

?>

但是这一次在 chrome 浏览器上的输出是: 您的浏览器不支持视频标签。


弑天下
浏览 105回答 2
2回答

撒科打诨

,如果回显中有另一个字符串,则无需提及变量就必须将其连接起来。并且您还必须在变量后指定一个空格,以便不与变量连接的类型。将您的代码更改为<?php$link='"https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1"';echo '<video controls="" height="640" width="720">&nbsp; <source src='. $link. ' type="video/mp4"></source>&nbsp; Your browser does not support the video tag.</video></body></html>';&nbsp;

慕姐8265434

变量的调用一定要正确,如下:<?php&nbsp; &nbsp; $link = 'https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1';?><!DOCTYPE html><html>&nbsp; &nbsp; <head>&nbsp; &nbsp; &nbsp; &nbsp; <title>Test Video</title>&nbsp; &nbsp; </head>&nbsp; &nbsp; <body>&nbsp; &nbsp; &nbsp; &nbsp; <video controls="" height="640" width="720">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <source src="<?php echo $link; ?>" type="video/mp4"></source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <source src="<?php echo $link; ?>" type="video/webm"></source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Your browser does not support the video tag.&nbsp; &nbsp; &nbsp; &nbsp; </video>&nbsp; &nbsp; </body></html>
打开App,查看更多内容
随时随地看视频慕课网APP