在php中调用header函数时出现解析错误
我有一个简单的php代码在php中调用header函数时出现解析错误,php,Php,我有一个简单的php代码 header(‘Content-type: application/json’); header(200 OK WORKED); $response[‘a’] = ‘test’; $json_response = json_encode($response); echo $json_response; 当我请求这个文件时,我在第2行得到一个“解析错误” 请帮助您的报价有误 而不是 header(‘Content-type: application/json’); 使
header(‘Content-type: application/json’);
header(200 OK WORKED);
$response[‘a’] = ‘test’;
$json_response = json_encode($response);
echo $json_response;
当我请求这个文件时,我在第2行得到一个“解析错误”
请帮助您的报价有误
header(‘Content-type: application/json’);
使用
$response[‘a’] = ‘test’;
应在哪里:
$response['a'] = 'test';
header(200 OK WORKED);
您可能应该在此处使用引号:
header('200 OK WORKED');
但事实上没有这样的地位一定要使用专门为编程而设计的编辑器,也就是说,不要使用能够替换引号(如
”
)的编辑器来修饰”
,或者自动将其大写的编辑器。如果您不能在为编程而设计的编辑器中编写,那么普通记事本或记事本++就可以了。
header('200 OK WORKED');