Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP error handling

  • 07-06-2008 01:18AM
    #1
    Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭


    I've got a class that handles my errors, and it seems to work okay. However, I have most of my content in include files and if it comes across an error in there, it appears to bubble back up, and not show the file or line that caused the error. For example:

    File A (includes error handler class)
    Line 40: include B.php

    File B
    Line 80: use a variable that doesn't exist (this is USER_NOTICE type error if that makes any diff)

    However, when this error is handled, it only shows A.php line 40. I'm putting the debug_backtrace into an array and printing that out gives me:
    Array
    (
        [0] => Array
            (
                [file] => A.php
                [line] => 40
                [args] => Array
                    (
                        [0] => B.php
                    )
    
                [function] => include_once
            )
    
    )
    
    So I can see the included file in the args array but no line number. If I change the included file so that it contains functions that I call from A.php, I get
    Array
    (
        [0] => Array
            (
                [file] => A.php
                [line] => 40
                [function] => display
                [args] => Array
                    (
                    )
    
            )
    
    )
    
    No args value this time. It must be possible to trace the line number of the INCLUDEd file that raised the error, and I'm pretty sure it's something dumb I'm doing, but my google-fu is letting me down.


Comments

Advertisement