Edit report at http://bugs.php.net/bug.php?id=52593&edit=1
ID: 52593 Comment by: dragoo...@php.net Reported by: hpolthof at gmail dot com Summary: Getting scope variables of the caller function Status: Open Type: Feature/Change Request Package: *General Issues PHP Version: 5.2.14 Block user comment: N New Comment: Please elaborate on "such a function does not exist" with an exact error message. Previous Comments: ------------------------------------------------------------------------ [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