php wamp 中的脚本给出错误 "not recognized as an internal or external command"

php script in wamp giving error "not recognized as an internal or external command"

<html>
<body>
<h2>xxxxxx!</h2>

<script language="php">

$score = array();
exec("D:\Users\Owner\Documents\a2 2>&1 D:\Users\Owner\Documents2.wav D:\Users\Owner\Documents\StartUpsw1.wav", $score);
#echo "<h3>Score </h3>\n";
echo "<br />xxxxxxx: $score[0]\n";
</script>

</body>
</html>

错误信息:

'D:\Users\Owner\Documents\a2' is not recognized as an internal or external command,

您不能 运行 PHP 以这种方式编码,PHP 仅存在于服务器上,这就是您向浏览器标记要 运行 的方式像 javascript

这样的客户端语言

所以你可以试试

<html>
<body>
<h2>xxxxxx!</h2>
<?php
    $score = array();
    exec("D:\Users\Owner\Documents\a2 2>&1 D:\Users\Owner\Documents2.wav D:\Users\Owner\Documents\StartUpsw1.wav", $score);
    echo '<h3>Score </h3>';
    echo '<br />';
    echo 'xxxxxxx: ' . $score[0];
?>
</body>
</html>

当服务器在将页面发送到浏览器之前准备页面时,您的代码现在将是 运行,我认为这就是您想要做的。

你也不需要到处都是 \n,那只会产生不必要的噪音和额外的字节来传输到浏览器,浏览器会忽略它们。