Edit report at http://bugs.php.net/bug.php?id=52593&edit=1
ID: 52593 Updated by: der...@php.net Reported by: hpolthof at gmail dot com Summary: Getting scope variables of the caller function -Status: Open +Status: Bogus Type: Feature/Change Request Package: *General Issues PHP Version: 5.2.14 Block user comment: N New Comment: . Previous Comments: ------------------------------------------------------------------------ [2010-08-12 15:36:33] hpolthof at gmail dot com Multiple levels are in my opinion not necessary, neighter the way of implementation. The scope variables could also be made available thru the backtrace() function. And still have no official support. @dragoonis: I don't know how more specific it can get. get_caller_vars() is a non-existent function. Hence this feature request! ------------------------------------------------------------------------ [2010-08-12 15:10:27] johan...@php.net Then you also need get_callers_caller_vars() and get_callers_callers_caller_vars() but by definition a function shall be independent from the caller's scope. All required information shall be passed as parameter. ------------------------------------------------------------------------ [2010-08-12 15:05:21] dragoo...@php.net Please elaborate on "such a function does not exist" with an exact error message. ------------------------------------------------------------------------ [2010-08-12 14:45:51] hpolthof at gmail dot com Description: ------------ In bug #48290 was the function get_caller_vars() suggested. But in that case it was irrelevant. However do I seek such a function. get_defined_vars() returns the vars in the current scope. As do i like to get the variables of the caller routine. This would allow me to use parameters from a subroutine without having to refactor another parameter being get_defined_vars() as this would obviously uglify my code, which would impeach the reason to refactor in the first place. Test script: --------------- function a() { $test = 'A'; b(); } function b() { $test = 'B'; $vars_local = get_defined_vars(); $vars_caller = get_caller_vars(); echo $vars_caller['test']; // Expexted: A echo $vars_local['test']; // Expected: B } a(); Expected result: ---------------- A B Actual result: -------------- such a function does not exist ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52593&edit=1