php.net |  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
Votes:1
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: beckman at purplecow dot com
New email:
PHP Version: OS:

 

 [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
    wine.inc --> calls function in
        db.inc --> calls error handling function in
    wine.inc --> prints error nicely and exits

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

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

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

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?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-23 15:22 UTC] derick@php.net
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 (Xdebug.derickrethans.nl) which has functions for this.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 19:01:33 2024 UTC