note 89472 added to function.define

From: Date: Mon, 09 Mar 2009 21:03:47 +0000
Subject: note 89472 added to function.define
Groups: php.notes 
Request: Send a blank email to php-notes+get-151669@lists.php.net to get a copy of this message
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); ?> ---- Server IP: 212.124.37.9 Probable Submitter: 79.226.178.79 ---- Manual Page -- http://www.php.net/manual/en/function.define.php Edit -- https://master.php.net/note/edit/89472 Del: integrated -- https://master.php.net/note/delete/89472/integrated Del: useless -- https://master.php.net/note/delete/89472/useless Del: bad code -- https://master.php.net/note/delete/89472/bad+code Del: spam -- https://master.php.net/note/delete/89472/spam Del: non-english -- https://master.php.net/note/delete/89472/non-english Del: in docs -- https://master.php.net/note/delete/89472/in+docs Del: other reasons-- https://master.php.net/note/delete/89472 Reject -- https://master.php.net/note/reject/89472 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151669) next »