|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-03-22 15:37 UTC] reeze@php.net
[2013-03-22 15:37 UTC] reeze@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To:
+Assigned To: reeze
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 16:00:01 2025 UTC |
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(); ?>