通过包含 PHP 变量嵌入视频时在 HTML 文件中出现意外结果
Getting unexpected result in HTML file while embedding video by including PHP variables
试图将 link 放入变量中并如下调用它(作为 .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 浏览器上得到了未扩展的输出:
enter image description here
我也尝试使用以下代码破坏 .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 浏览器上的输出是:
您的浏览器不支持视频标签。
变量的调用一定要正确,如下:
<?php
$link = 'https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1';
?>
<!DOCTYPE html>
<html>
<head>
<title>Test Video</title>
</head>
<body>
<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>
你没有用 ,
提到一个变量,如果你在回显中有另一个字符串,你必须连接它。并且你还必须在变量后指定一个space,以便类型不与变量连接。
将代码更改为
<?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>
Your browser does not support the video tag.
</video>
</body>
</html>';
试图将 link 放入变量中并如下调用它(作为 .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 浏览器上得到了未扩展的输出:
enter image description here
我也尝试使用以下代码破坏 .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 浏览器上的输出是: 您的浏览器不支持视频标签。
变量的调用一定要正确,如下:
<?php
$link = 'https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1';
?>
<!DOCTYPE html>
<html>
<head>
<title>Test Video</title>
</head>
<body>
<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>
你没有用 ,
提到一个变量,如果你在回显中有另一个字符串,你必须连接它。并且你还必须在变量后指定一个space,以便类型不与变量连接。
将代码更改为
<?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>
Your browser does not support the video tag.
</video>
</body>
</html>';