PHP Parse错误:语法错误,第56行

时间:2018-10-08 08:30:04

标签: php arrays select multidimensional-array jq

$cm_json = exec('curl -H "Accept: application/vnd.pagerduty+json;version=2" -H "Authorization: Token token="XXXXXXX" -X GET -G  "https://api.pagerduty.com/users/'.$user_id.'/contact_methods/" | jq '.contact_methods[] | select(.label == "Mobile") | .address'');
  

PHP解析错误:语法错误,第56行出现意外的'['

1 个答案:

答案 0 :(得分:0)

您遇到报价问题。在jq过滤器的单引号前使用baskslash:

$cm_json = exec('curl -H "Accept: application/vnd.pagerduty+json;version=2" -H "Authorization: Token token="XXXXXXX" -X GET -G  "https://api.pagerduty.com/users/'.$user_id.'/contact_methods/" | jq \'.contact_methods[] | select(.label == "Mobile") | .address\'');