From: rkressirer at t-online dot de
Operating system: WIN2K
PHP version: 5.0.0
PHP Bug Type: Class/Object related
Bug description: no string variable allowed in function get_class_vars and
get_class_methods
Description:
------------
For to analyse objects the following function was written. According to
the manual it should be possible to use a 'string class_name' as variable
in the functions get_class_vars() and get_class_methods().
It turned out, that this is not the case. Only by replacing the variable
(in this case 'KlassenName') by the function get_class($obj) the required
result will be obtained.
The code shows both versions of each function and the respective Error
Message.
(windows+apache1.x+php module version on localhost)
Reproduce code:
---------------
function object_structure($obj)
{
print ("Klasse: ".$KlassenName= (get_class($obj))."<br>");
$properties = (get_object_vars($obj));
while (list($prop, $val) = each($properties))
echo "$prop = $val<br>";
//---------------------------------------------------------
//works:
$stdClassVars = (get_class_vars(get_class($obj)));
while (list($prop) = each($stdClassVars))
echo "Standardelement: $prop<br>";
//does not work:
//Warning: Variable passed to each() is not an array or object in
f:\programme\apache...
$stdClassVars = (get_class_vars($KlassenName));
while (list($prop) = each($stdClassVars))
echo "Standardelement: $prop<br>";
//---------------------------------------------------------//works:
$methods = (get_class_methods(get_class($obj)));
foreach ($methods as $method) print("Methode: ".$method."<br>");
//does not work:
//Warning: Invalid argument supplied for foreach() in f:\programme...
$methods = (get_class_methods($KlassenName));
foreach ($methods as $method) print("Methode: ".$method."<br>");
return;
}
?>
Expected result:
----------------
any existing class_variable or method of an object should be shown with
both versions.
For testing I used:
class baugruppe{
public $BG_ID, $BG_NAME, $BG_NR='421500.000', $Version='d';
function __construct($BG_ID, $BG_NAME)
{
$this->BG_ID =$BG_ID;
$this->BG_NAME=$BG_NAME;
return;
}
function show()
{
echo "$this->BG_ID<br>";
echo "$this->BG_NR<br>";
echo "$this->BG_NAME<br>";
echo "$this->Version<br>";
return;
}
} //end class
$transferarm= new baugruppe(3,'Transferarm');
Actual result:
--------------
only version marked with "works" shows results.
--
Edit bug report at http://bugs.php.net/?id=29774&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29774&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29774&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29774&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29774&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29774&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29774&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29774&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29774&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29774&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29774&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29774&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29774&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29774&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29774&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29774&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29774&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29774&r=float