note 128440 added to function.define

From: Date: Sun, 30 Apr 2023 00:33:49 +0000
Subject: note 128440 added to function.define
Groups: php.notes 
Request: Send a blank email to php-notes+get-220395@lists.php.net to get a copy of this message
Since version 8 or 8.1, beat me if I recall any type of class as defined constant value is perfectly valid. Should You use it, I wouldn't know. Most probably, referencing with such instances will fail badly. But it might come handy for public and readonly classes. <?php define ('ClassInstance', new class extends \My\OtherClass { private bool $toggle = false; private float $real = 1.2345; private ?string $obj = null; public function __construct() { $this-> privatemethod(); } private function privatemethod() { $this-> obj = var_export ($this, true); } }); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.130 (proxied: 45.86.56.129) ---- Manual Page -- https://php.net/manual/en/function.define.php Edit -- https://main.php.net/note/edit/128440 Del: integrated -- https://main.php.net/note/delete/128440/integrated Del: useless -- https://main.php.net/note/delete/128440/useless Del: bad code -- https://main.php.net/note/delete/128440/bad+code Del: spam -- https://main.php.net/note/delete/128440/spam Del: non-english -- https://main.php.net/note/delete/128440/non-english Del: in docs -- https://main.php.net/note/delete/128440/in+docs Del: other reasons-- https://main.php.net/note/delete/128440 Reject -- https://main.php.net/note/reject/128440 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220395) next »