php - VSCode + Xdebug。逐步调试退出递归栈
问题描述
我正在使用VSCode + PHP + Xdebug。写了一个递归函数,试图调试它。但是当调试器到达堆栈的末尾“ return true ”时,它不会返回堆栈,它只是退出。我认为递归可能很糟糕。我用最简单的例子试过了,但还是一样。
例如:
function pow1($x, $n)
{
if ($n == 1) {
return $x;
} else {
return $x * pow1($x, $n - 1);
}
}
$result = pow1(2, 3);
echo $result;
调试器达到return $x; 并以正确的结果退出堆栈。
pow1 (d:\OpenServer\OSPanel\domains\localhost\index.php:6)
pow1 (d:\OpenServer\OSPanel\domains\localhost\index.php:8)
pow1 (d:\OpenServer\OSPanel\domains\localhost\index.php:8)
{main} (d:\OpenServer\OSPanel\domains\localhost\index.php:12)
并跳到这里:
{main} (d:\OpenServer\OSPanel\domains\localhost\index.php:14)
我爬上了所有的 Xdebug 设置,尝试了不同的选项,但都没有帮助。将函数重写为JavaScript并在浏览器中调试。
解决方案
推荐阅读
- python - python中的multiprocessing.process,用于使用共享队列中的值的并行进程
- java - 使用 whereArrayContains 搜索的效率
- reactjs - 如何在反应函数中声明变量?
- json - Highcharts 官方 + React,来自 JSON 的系列人口?
- javascript - Enter 键不能用作按钮
- python - python vs. R 作用域
- notepad++ - 更改缩进的颜色
- css - CSS className 没有对 Reactjs 进行任何更改
- java - 在另一个 ArrayList 中找到 JButton 源
- r - 在 mac OS high sierra 中安装 data.table 时出现 clang 错误