Req #52593 [Com]: Getting scope variables of the caller function

From: Date: Thu, 12 Aug 2010 13:05:21 +0000
Subject: Req #52593 [Com]: Getting scope variables of the caller function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153368@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52593&edit=1 ID: 52593 Comment by: dragoonis@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

« previous php.bugs (#153368) next »