你如何调试PHP脚本?
我知道基本调试,例如使用错误报告.PHPEclipse中的断点调试也非常有用.
在phpStorm或任何其他IDE中调试的最佳方法(快速简便)是什么?
我有一个 PHP 脚本,它使用该exec函数来执行 Node 脚本并将一些数据返回到同一 PHP 脚本。
我的问题是我需要将数据返回给 PHP,而不必等待清理代码完成finally。
我在下面编写了一些示例代码,向您展示代码的流程并说明我的问题。该代码示例不使用任何节点模块,但如果它们有帮助,请随意使用它们。
示例.php
$data = 'hello world';
$exec = 'node example.js ' . $data;
$escaped_command = escapeshellcmd($exec);
$data = exec($escaped_command);
// waits 10 seconds then displays returned data
// I need the code to return before finally executes
var_dump($data); // string(31) "Final data is final hello world"
Run Code Online (Sandbox Code Playgroud)
示例.js
let data = process.argv[2];
// let data = "hello world";
async function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); …Run Code Online (Sandbox Code Playgroud)