|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #20049 __PARENTFILE__ and __PARENTLINE__ constants
Submitted: 2002-10-23 14:57 UTC Modified: 2002-10-23 15:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: beckman at purplecow dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.2.3 OS: FreeBSD 4.7
Private report: No CVE-ID: None
 [2002-10-23 14:57 UTC] beckman at purplecow dot com
I'm writing a script which calls a function which handles errors.  The function lies in a different file (it was included) than where the function was called.

index.php --> calls function in --> calls function in --> calls error handling function in --> prints error nicely and exits

at index.php __PARENTFILE__ would be "" and __PARENTLINE__ would be "".

At __PARENTFILE__ would be "/path/to/index.php" and __PARENTLINE__ would be the line number where we left index.php (called the function in

At __PARENTFILE__ would be "/path/to/" and __PARENTLINE__ would be the line number where we left (where the function called was in

Make sense?  I couldn't find ANYTHING in documentation that allowed such a view into the system.

A $_EXECUTION like global would be nice too, showing at the point called which files were open (either through includes or requires or FOPENs) and the line numbers they were at at the time of calling.  Or maybe this would be more proper as a function returning an array of information?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-23 15:22 UTC]
You can do this with the debug_backtrace() function in PHP 4.3.0 or higher. This is not exactly the same, but for now the only way to do this (technically). The __*__ constants are replaced during compile time and as it is (almost) impossible to get this date from the parent file. You can also have a look at xdebug ( which has functions for this.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 05 05:01:29 2024 UTC