首頁 php教程 php手册 php Exception打印error trace 实例

php Exception打印error trace 实例

May 25, 2016 pm 04:44 PM
error exception trace 實例

本文章来给各位同学介绍关于php Exception打印error trace 实例,对于php的Exception,可以通过getTraceAsString获得错误,而对于error则应该如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

<?php

function x() $x = debug_backtrace();

//remove stack of this function

array_shift($x);

$i = 0;

$xstr = &#39;&#39;;

foreach ($trace as $x) {

    //TODO need check exists args

    $args = $x[&#39;args&#39;];

    if (!$args) {

        $argstr = &#39;&#39;;

    } else {

        $argstr = &#39;&#39;;

        $first = true;

        foreach ($args as $arg) {

            if (!$first) {

                $argstr.= &#39;,&#39;;

            }

            $first = false;

            if (is_object($arg)) {

                $argstr.= &#39;Object[&#39; . get_class($arg) . &#39;]&#39;;

            } elseif (is_array($arg)) {

                $argstr.= &#39;Array&#39;;

            } else {

                $argstr.= $arg;

            }

        }

    }

    $xstr.= "[#$i] {$x[&#39;file&#39;]}({$x[&#39;line&#39;]}) {$x[&#39;function&#39;]} ($argstr)" . PHP_EOL;

    $i++;

}

return $xstr;

}

?>

登入後複製


教程网址:

欢迎收藏∩_∩但请保留本文链接。

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章

倉庫:如何復興隊友
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章

倉庫:如何復興隊友
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章標籤

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

PHP Fatal error: Call to undefined method PDO::prepare() in的解決方法 PHP Fatal error: Call to undefined method PDO::prepare() in的解決方法 Jun 22, 2023 pm 06:40 PM

PHP Fatal error: Call to undefined method PDO::prepare() in的解決方法

解決C++程式碼中出現的「error: incomplete type is not allowed」問題 解決C++程式碼中出現的「error: incomplete type is not allowed」問題 Aug 26, 2023 pm 08:54 PM

解決C++程式碼中出現的「error: incomplete type is not allowed」問題

在Vue應用程式中使用axios時出現「Uncaught (in promise) Error: Request failed with status code 500」怎麼辦? 在Vue應用程式中使用axios時出現「Uncaught (in promise) Error: Request failed with status code 500」怎麼辦? Jun 24, 2023 pm 05:33 PM

在Vue應用程式中使用axios時出現「Uncaught (in promise) Error: Request failed with status code 500」怎麼辦?

解決C++程式碼中出現的「error: expected initializer before 'datatype'」問題 解決C++程式碼中出現的「error: expected initializer before 'datatype'」問題 Aug 25, 2023 pm 01:24 PM

解決C++程式碼中出現的「error: expected initializer before 'datatype'」問題

如何解決PHP Warning: fopen(): failed to open stream: No such file or directory 如何解決PHP Warning: fopen(): failed to open stream: No such file or directory Aug 19, 2023 am 10:44 AM

如何解決PHP Warning: fopen(): failed to open stream: No such file or directory

Python中的SVM實例 Python中的SVM實例 Jun 11, 2023 pm 08:42 PM

Python中的SVM實例

Java中的ConcurrentModificationException異常的產生原因和解決方法 Java中的ConcurrentModificationException異常的產生原因和解決方法 Jun 25, 2023 am 10:33 AM

Java中的ConcurrentModificationException異常的產生原因和解決方法

PHP Fatal error: Call to undefined function mysqli_connect()的解決方法 PHP Fatal error: Call to undefined function mysqli_connect()的解決方法 Jun 23, 2023 am 09:40 AM

PHP Fatal error: Call to undefined function mysqli_connect()的解決方法

See all articles