From:             William dot McGuire at solacedev dot com
Operating system: Win XP
PHP version:      5.3.1
PHP Bug Type:     Feature/Change Request
Bug description:  Variable Variable with $this->

Description:
------------
Consider 2 classes

class user
class reports extends user

user stores public variables such as public $username using
$this->username;

I want to be able to dynamically say in class reports

echo $this->$field where $field = "username", "first_name" etc.

Reproduce code:
---------------
---
>From manual page: http://www.php.net/language.variables.variable
---
class user {
public $username;

function username() { 
//queries from db table and gets
$this->username = $username; //from table
}

class reports extends user {
function userInfo($gid,$arrFieldstoReport) {
parent::__construct($gid)
//loop through $arrFieldstoReport
echo "username = " . $this->arrFieldstoReport[$i]
}
}

Expected result:
----------------
This should echo the following if $arrFieldstoReport[$i] = "username"

echo $this->arrFieldstoReport[$i];
//should echo 
username = testusername (or any other username depending on what group_id
it is on)


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

Reply via email to