Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    478
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Can I get info of which file and line number made a call to my own function?

    Is it possible to get the file and line number where a call was made to a function?

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Hello,

    Yes for the current line and file you can use the magic constants __LINE__ and __FILE__.

    For the call stack, you can use debug_backtrace() though you'll want to run that through var_dump(). It will give you an array of arrays with things like function names, line numbers etc.
    I can't really think of anything to write here now...

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Posts
    478
    Thanks
    7
    Thanked 3 Times in 3 Posts
    ah, thank you for this, I shall look in to it more and see if this can help me.

    Cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •