# 如何從debug_backtrace函數中刪除敏感數據？

## 最佳答案

Aha ...想通了如果我序列化debug_backtrace數組然後立即反序列化它，結果數組將缺少原始數組的遞歸引用，我可以安全地遞歸叠代它。

$backtrace = debug_backtrace();$backtrace = serialize($backtrace);$backtrace = unserialize($backtrace); recursive_sanitization_func($backtrace);


EDIT: Okay, so this isn't a complete solution. It works for recursive objects references (they are lost) but not for recursive arrays (they are retained).

My current solution is to serialize/unserialize as above, and then run the resulting array through a recursion-detection function such as that described here: http://www.php.net/manual/en/ref.array.php#96914