在PHP中,是否可以将最后一次curl尝试的语法作为字符串?

时间:2015-05-10 14:20:28

标签: php linux curl

偶尔我想通过在Linux终端中运行实际的curl命令来调试curl请求是否有可能以String格式获取PHP生成的命令以获取curl命令,这样的话?

curl -X PUT \
-H "x-pushbots-appid: 54cc0a511d0ab13c0528b459d" \
-H "x-pushbots-secret: 1444fe8be3324ff7128f25aa18cdee12" \
-H "Content-Type: application/json" \
-d '{ "token" : String ,  "platform" : String ,  "lat" : String ,  "lng" : String ,  "active" : Array ,  "tag" : Array ,  "alias" : String  }' \
https://api.pushbots.com/deviceToken

1 个答案:

答案 0 :(得分:1)

您需要避免执行CLI,因为调试它非常困难。我建议你使用PHP的cURL扩展(http://php.net/manual/en/ref.curl.php)然后你可以调试:

  1. Try-Catch(异常处理)
  2. error_get_last()
  3. function()或die(“--- log / break code - ”);