Req #62520 [Opn->Csd]: Feature request: Anonymous Class
Edit report at https://bugs.php.net/bug.php?id=62520&edit=1
ID: 62520
Updated by: danack@php.net
Reported by: k at webnfo dot com
Summary: Feature request: Anonymous Class
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: *General Issues
PHP Version: Irrelevant
-Assigned To:
+Assigned To: danack
Block user comment: N
Private report: N
New Comment:
Anonymous classes were implemented in PHP 7.
http://php.net/manual/en/language.oop5.anonymous.php
Previous Comments:
------------------------------------------------------------------------
[2015-08-08 22:12:25] php at mcq8 dot be
This actually works in php7 (https://wiki.php.net/rfc/anonymous_classes)
------------------------------------------------------------------------
[2012-07-10 05:10:15] k at webnfo dot com
Description:
------------
The syntax imagined as below (Define And Initiate An Anonymous Class):
$object = (new class($param1, $param1){
public $var1 = 'abc'
public function test(){
echo $this->var1;
}
});
$object->test();
out: 'abc'
============ Or Alternatively ===================
(new class($param1, $param1){
public $var1 = 'abc'
public function test(){
echo $this->var1;
}
})->test();
out: 'abc'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62520&edit=1
Thread (3 messages)