WAMP 中的 PHP 脚本给出错误“未识别为内部或外部命令”


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'Documents'212.wav D:'Users'Owner'Documents'StartUp'23sw1.wav", $score);
#echo "<h3>Score </h3>'n";
echo "<br />xxxxxxx: $score[0]'n";
</script>
</body>
</html>

错误信息:

"D:''用户''所有者''文档''a2"未被识别为内部或外部命令,

你不能以这种方式运行PHP代码,PHP只存在于服务器上,这就是你向浏览器标记你想要运行客户端语言的方式,比如javascript

所以你可以试试

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

您的代码现在将在服务器准备页面时运行,然后再将其发送到浏览器,我假设这就是您想要做的。

此外,您不需要到处都使用'n,这只会产生不必要的噪音和额外的字节以传输到浏览器,浏览器将忽略它们。