note 128137 added to function.define

From: Date: Sat, 21 Jan 2023 12:19:39 +0000
Subject: note 128137 added to function.define
Groups: php.notes 
Request: Send a blank email to php-notes+get-220092@lists.php.net to get a copy of this message
Those who simply cannot look at $erpent or Dollar Sign any longer, could actually try the following: <?php define ('Instance', new class { public function globalDump (string $index) { $SuperGlob = '_' . mb_strtoupper ($index); return ($GLOBALS[$SuperGlob] ?? $GLOBALS[$index] ?? $this); } }); header ('Content-Type: text/plain'); exit (print_r (Instance-> globalDump ('server'), true)); ?> Since named constant can have entire class as value, it will eliminate the need for $ before calling-in/typing any public method in the procedural scope. However, TOTALLY eliminating so much hated $ sign is still not possible, nor anyone should have that much emotional approach towards any language. NOTE that object instance as NAMED CONSTNAT value might and most probably will give unexpected results here and there, so I wouldn't consider this as preferred style. ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.158.213 (proxied: 45.86.56.129) ---- Manual Page -- https://php.net/manual/en/function.define.php Edit -- https://main.php.net/note/edit/128137 Del: integrated -- https://main.php.net/note/delete/128137/integrated Del: useless -- https://main.php.net/note/delete/128137/useless Del: bad code -- https://main.php.net/note/delete/128137/bad+code Del: spam -- https://main.php.net/note/delete/128137/spam Del: non-english -- https://main.php.net/note/delete/128137/non-english Del: in docs -- https://main.php.net/note/delete/128137/in+docs Del: other reasons-- https://main.php.net/note/delete/128137 Reject -- https://main.php.net/note/reject/128137 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220092) next »