Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel Json响应函数_Php_Json_Extjs - Fatal编程技术网

Php Laravel Json响应函数

Php Laravel Json响应函数,php,json,extjs,Php,Json,Extjs,我目前正在LaravelV4.2.11中开发一个应用程序,它使用ExtJSV4.2.1-gpl 作为我的ExtJS应用程序的一部分,我正在开发一个由ExtJS使用的JSON响应。但是,我想做以下事情: return Response::json(array( 'menusystem' => array( 'listeners' => array( 'click' => function() { location.href = 'test'

我目前正在LaravelV4.2.11中开发一个应用程序,它使用ExtJSV4.2.1-gpl

作为我的ExtJS应用程序的一部分,我正在开发一个由ExtJS使用的JSON响应。但是,我想做以下事情:

return Response::json(array(
  'menusystem' => array(
    'listeners' => array(
      'click' => function() {
        location.href = 'test'
      }
    )
  )
);

我知道这不是有效的JSON。然而,以前的应用程序开发人员就是这样做的。我想知道这在PHP、Laravel或JSON中是否可行。

您可以这样做

$response = array(
  'menusystem' => array(
    'listeners' => array(
      'click' => "%%%function() {
        location.href = 'test'
      }%%%"
    )
  )
);

$response = json_encode($response);
$response = str_replace('"%%%', '', $response);
$response = str_replace('%%%"', '', $response);
return $response;

这只是一般的概念。您可以在特殊宏等中检测函数结构。

您到底想做什么?以前的开发人员实际上做了什么?还有,PHP语言!=Laravel php框架!=JSON数据格式