From:             
Operating system: 
PHP version:      5.2.14
Package:          *General Issues
Bug Type:         Feature/Change Request
Bug description:Getting scope variables of the caller function

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 bug report at http://bugs.php.net/bug.php?id=52593&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52593&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52593&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52593&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52593&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52593&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52593&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52593&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52593&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52593&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52593&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52593&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52593&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52593&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52593&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52593&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52593&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52593&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52593&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52593&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52593&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52593&r=mysqlcfg

Reply via email to