note 123958 added to errorfunc.constants

From: Date: Wed, 19 Jun 2019 10:39:32 +0000
Subject: note 123958 added to errorfunc.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-211311@lists.php.net to get a copy of this message
A shorter version of vladvarna's FriendlyErrorType($type) <?php function getErrorTypeByValue($type) { $constants = get_defined_constants(true); foreach ( $constants['Core'] as $key => $value ) { // Each Core constant if ( preg_match('/^E_/', $key ) ) { // Check error constants if ( $type == $value ) return( "$key=$value"); } } } // getErrorTypeByValue() echo "[".getErrorTypeByValue( 1 ) . "]". PHP_EOL; echo "[".getErrorTypeByValue( 0 ) . "]". PHP_EOL; echo "[".getErrorTypeByValue( 8 ) . "]". PHP_EOL; ?> Will give [E_ERROR=1] [] [E_NOTICE=8] ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.195 (proxied: 188.64.152.196) ---- Manual Page -- http://php.net/manual/en/errorfunc.constants.php Edit -- https://master.php.net/note/edit/123958 Del: integrated -- https://master.php.net/note/delete/123958/integrated Del: useless -- https://master.php.net/note/delete/123958/useless Del: bad code -- https://master.php.net/note/delete/123958/bad+code Del: spam -- https://master.php.net/note/delete/123958/spam Del: non-english -- https://master.php.net/note/delete/123958/non-english Del: in docs -- https://master.php.net/note/delete/123958/in+docs Del: other reasons-- https://master.php.net/note/delete/123958 Reject -- https://master.php.net/note/reject/123958 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#211311) next »