Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

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