From: msaspence at gmail dot com
Operating system:
PHP version: 5.2.5
PHP Bug Type: Feature/Change Request
Bug description: new function get_object_name()
Description:
------------
Currently to get the objects variable name within the object you must pass
it as a parameter and have the constructor define it.
This solution while simple would be tidier if there was a function that
could retrieve the object's variable instance from inside itself.
Reproduce code:
---------------
Currently
<?php
class myClass {
function __construct($objectName) {
$this->objectName = $objectName;
}
function printName() {
echo "the name of this object instance is ".$this->objectName;
}
}
$object = 'myObject';
$$object = new myClass('$object');
$$object->printName();
?>
Expected result:
----------------
How it might be done:
<?php
class myClass {
function printName() {
echo "the name of this object instance is
".$this->get_object_name();
}
}
$object = 'myObject';
$$object = new myClass;
$$object->printName();
?>
--
Edit bug report at http://bugs.php.net/?id=44282&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44282&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44282&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44282&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44282&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44282&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44282&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44282&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44282&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44282&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44282&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44282&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44282&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44282&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44282&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44282&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44282&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44282&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44282&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44282&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44282&r=mysqlcfg