cmb69 · GitHub

@TysonAndre

This can be polyfilled with
`min($limit, count(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)))`.
- For debug_backtrace, the limit is to the number of frames scanned,
  not the size of the returned array.
- For debug_backtrace_depth, the limit is on the returned depth)
It's faster just to not read the filenames, lines, create temporary arrays, etc.
This can be useful if you are checking for infinite recursion
to investigate a bug in an application.
E.g. `return debug_backtrace_depth(1000) >= 1000` would check
if php is more than 1000 stack frames of debug_backtrace deep.
This may have other uses, such as more efficiently
computing an indentation level in logging statements.
```
Processing Node A
  Processing Node B
    Processing Leaf C
    Processing Leaf D
```
Note that php stack frames are a linked list - the amount of time to compute the
depth is proportional to the depth, and some frames do not show up in backtraces.
This PHP stack is separate from the C stack.

Read the original on github.com ↗