note 127530 added to language.oop5.basic
| From: | razvan_bc.yahoo.com via php-notes | Date: | Wed, 24 Aug 2022 14:19:46 +0000 |
| Subject: | note 127530 added to language.oop5.basic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219469@lists.php.net to get a copy of this message | ||
there are other ways to emulate a class and to "extend" it not in new extended "class
" but by growing same "class" .
i test this code in php 8.2 beta 3 :
<?php
$class=[
'show'=>function($msg='da'){
echo $msg;
}
,'add'=>function($x,$y){
return $x+$y;
}
,'extend'=>function($propname,$obj){
$GLOBALS['class'][$propname]=$obj;
$GLOBALS['_']=(object)$GLOBALS['class'];
}
];
$_=(object)$class;
($_->show)('nothing or all');
//'extend' part
($_->extend)('trickyextend',function(){echo '..and more..';});
($_->trickyextend)();
($_->extend)('whatwhowhere',function($msg){echo $msg;});
($_->whatwhowhere)('why php!');
?>
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.175 (proxied: 5.14.159.181)
----
Manual Page -- https://php.net/manual/en/language.oop5.basic.php
Edit -- https://main.php.net/note/edit/127530
Del: integrated -- https://main.php.net/note/delete/127530/integrated
Del: useless -- https://main.php.net/note/delete/127530/useless
Del: bad code -- https://main.php.net/note/delete/127530/bad+code
Del: spam -- https://main.php.net/note/delete/127530/spam
Del: non-english -- https://main.php.net/note/delete/127530/non-english
Del: in docs -- https://main.php.net/note/delete/127530/in+docs
Del: other reasons-- https://main.php.net/note/delete/127530
Reject -- https://main.php.net/note/reject/127530
Search -- https://main.php.net/manage/user-notes.php