我在我的小项目中使用HttpFoundation:use \Symfony\Component\HttpFoundation\JsonResponse as JsonResponse;
不幸的是,我的所有回复(已尝试JsonResponse
,Response
和BinaryFileResponse
)仅返回空白页,没有错误,代码正常执行,例如
/* Get Inputs */
if (!$data = filter_input(INPUT_GET, 'url', FILTER_VALIDATE_URL)) {
return new JsonResponse(array(
'result' => 'error',
'message' => 'URL is invalid or missing'
));
}else{
return new JsonResponse(array(
'result' => 'success',
'message' => 'FINE'
));
日志中也没有错误。
任何想法如何处理这个问题?
//澄清更新
$json = new JsonResponse(array(
'result' => 'error',
'message' => 'Encrypt is invalid or missing'
));
echo $json;
返回HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json {"result":"error","message":"Encrypt is invalid or missing"}
但为什么return
不起作用?