|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-18 16:08 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 03:00:01 2025 UTC |
Description: ------------ In building my own functions, in particular an include work-a-like that does some pre and post processing, it would be very handy to have a __CALLER__ constant that indicates the file the function was called from, and and a __CLINE__ constant or something similar that indicates the line number in the caller where the function was called from. It appears that the only way to accomplish this within PHP by having the function take __FILE__ and __LINE__ as parameters, which for an potentially oft used function makes for a lot of extra typing. Reproduce code: --------------- function my_include(file,caller,line) { echo "Called from: ",$caller,", line number: ", $line; include(file); } my_include(file,__FILE__,__LINE__); could be: function my_include(file) { echo "Called from: ", __CALLER__ , " , line number: ", __CLINE__; include(file); } my_include(file); Expected result: ---------------- Called from: SOMEFILE, line number: SOMEINT