生成的html显示php符号而不是值

生成的html显示php符号而不是值,php,html,audio,symbols,Php,Html,Audio,Symbols,我希望能够通过将源代码嵌入播放器来播放数据库中的所有音频文件 我创建了一个sql查询,它将返回一个包含我所有mp3名称的数组 然后我使用while循环 while($row = mysqli_fetch_array($result)) { $sourcefile=$row['location']; echo '<audio controls>'; echo '<source src="$sourcefile" type="audio/mpeg">'; echo "$sou

我希望能够通过将源代码嵌入播放器来播放数据库中的所有音频文件

我创建了一个sql查询,它将返回一个包含我所有mp3名称的数组

然后我使用while循环

while($row = mysqli_fetch_array($result)) {
$sourcefile=$row['location'];
echo '<audio controls>';
echo '<source src="$sourcefile" type="audio/mpeg">';
echo "$sourcefile";
echo '</audio>';
}
while($row=mysqli\u fetch\u数组($result)){
$sourcefile=$row['location'];
回声';
回声';
回显“$sourcefile”;
回声';
}
这将生成以下html:

<audio controls>
<source src="$sourcefile" type"audio/mpeg">
</audio>

如果我显式地用songname.mp3替换音频标记中的$sourcefile,它就可以正常工作

为了确保php变量得到了正确的值,我使用了一个echo语句来查看它包含的值,它确实是songname.mp3


有什么可能出错?

变量替换只发生在双引号字符串中,而不是单引号字符串中。更改它:

echo "<source src='$sourcefile' type='audio/mpeg'>";
echo”“;

变量替换只发生在双引号字符串中,而不是单引号字符串中。更改它:

echo "<source src='$sourcefile' type='audio/mpeg'>";
echo”“;

变量替换只发生在双引号字符串中,而不是单引号字符串中。更改它:

echo "<source src='$sourcefile' type='audio/mpeg'>";
echo”“;

变量替换只发生在双引号字符串中,而不是单引号字符串中。更改它:

echo "<source src='$sourcefile' type='audio/mpeg'>";
echo”“;
您可以尝试以下方法:

echo "<source src='{$sourcefile}' type='audio/mpeg'>";
echo”“;
或者这个:

<source src="<?php echo $sourcefile; ?>" type="audio/mpeg">
您可以尝试以下方法:

echo "<source src='{$sourcefile}' type='audio/mpeg'>";
echo”“;
或者这个:

<source src="<?php echo $sourcefile; ?>" type="audio/mpeg">
您可以尝试以下方法:

echo "<source src='{$sourcefile}' type='audio/mpeg'>";
echo”“;
或者这个:

<source src="<?php echo $sourcefile; ?>" type="audio/mpeg">
您可以尝试以下方法:

echo "<source src='{$sourcefile}' type='audio/mpeg'>";
echo”“;
或者这个:

<source src="<?php echo $sourcefile; ?>" type="audio/mpeg">


src=
之后的
结束字符串,这样就不起作用了。在
type
之后缺少
=
。Thanx about
=
after
type
但是关于
之后的
src=/code>它起作用了,因为我使用了
{}
而不是
$sorcefile.
,你自己试试。我建议你试试,你应该会得到一个语法错误。我刚试过,我得到了
解析错误:解析错误,应该是“,”或“;”现在它工作了,和我的答案一样。你不需要
{/code>,因为它是一个简单的变量。
之后的
src=
结束字符串,所以这不起作用。而且你缺少
=
之后的
=
类型
.Thanx关于
=
之后的
类型
。但是关于
之后的
src=/code>它起作用,因为我使用了
{}
不是
$sorcefile。
,你自己试试。我建议你试试,你应该会有语法错误。我刚试过,我得到
解析错误:解析错误,应该是“,”或“;”现在它工作了,和我的答案一样。你不需要
{/code>,因为它是一个简单的变量。
之后的
src=
结束字符串,所以这不起作用。而且你缺少
=
之后的
=
类型
.Thanx关于
=
之后的
类型
。但是关于
之后的
src=/code>它起作用,因为我使用了
{}
不是
$sorcefile。
,你自己试试。我建议你试试,你应该会有语法错误。我刚试过,我得到
解析错误:解析错误,应该是“,”或“;”现在它工作了,和我的答案一样。你不需要
{/code>,因为它是一个简单的变量。
之后的
src=
结束字符串,所以这不起作用。而且你缺少
=
之后的
=
类型
.Thanx关于
=
之后的
类型
。但是关于
之后的
src=/code>它起作用,因为我使用了
{}
不是
$sorcefile。
,你自己试试。我建议你试试,你应该会有语法错误。我刚试过,我得到
解析错误:解析错误,应该是“,”或“;”现在它工作了,和我的答案一样。您不需要
{}
,因为它是一个简单的变量。非常感谢。太好了。非常感谢。太好了。非常感谢。太好了。非常感谢你。