我无法修改函数内部的全局变量,也无法在浏览器上显示回显消息。请帮我为什么我无法在浏览器上回显任何内容
<!DOCTYPE html>
<html>
<body>
<?php
$response = array();
function() {
global $response['res']="hello";
echo json_encode($response);
}
echo "hello";
?>
</body>
</html>
你的代码没有按” t回声,因为它不能运行,因为它不能编译。 'global $ response ['res'] =“hello”;'是两个语句合并成一次(这不起作用)。尝试'全球$回应; $ response ['res'] =“hello”;' – axiac
您需要为您的函数命名并移除'global $ response [...]'。 – Script47
语法错误:response ['res'] =“hello”; '$' – Priya