note 89472 deleted from function.define by cmb

From: Date: Sun, 06 Oct 2019 07:55:42 +0000
Subject: note 89472 deleted from function.define by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212484@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- With php 5.30 it is possible to make some "restrictions", in case u use namespaces... The following function allows only uppercase and, if 3 param isset, gives E_USER_ERROR instead of E_NOTICE: <?php namespace bla; function define($c,$v,$x=false) { $c = strtoupper($c); if (!defined($c)) { // not to use \define here, as the syntax highlighting does not work correctly here... return define($c, $v, true); } else if ($x == true) { trigger_error('setting constant "'.$c.'" is not allowed', E_USER_ERROR); } return null; } define('PHP_VERSION', '1'); define('PHP_VERSION', '1') || trigger_error('constant already defined', E_USER_NOTICE); define('PHP_VERSION', '1', true); ?>

« previous php.notes (#212484) next »