note 127719 added to function.trim

From: Date: Thu, 13 Oct 2022 03:01:42 +0000
Subject: note 127719 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-219669@lists.php.net to get a copy of this message
I was puzzled by a warning "Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in ...", not mentioned on this manual page. In fact, this is about the first parameter (which should have index 0, not 1) which should/must not be NULL (but it can be ""), which occurs, e.g., if you use <?php if ( $value = trim( @$_REQUEST['value'] )) { ... } ?> in order to check whether a form's parameter stripped from whitespace is nonempty, and the form wasn't sent yet. To avoid the warning, you can use <?php if ( $value = @$_REQUEST['value'] and $value = trim( $value )) { ... } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.161 (proxied: 89.157.118.54) ---- Manual Page -- https://php.net/manual/en/function.trim.php Edit -- https://main.php.net/note/edit/127719 Del: integrated -- https://main.php.net/note/delete/127719/integrated Del: useless -- https://main.php.net/note/delete/127719/useless Del: bad code -- https://main.php.net/note/delete/127719/bad+code Del: spam -- https://main.php.net/note/delete/127719/spam Del: non-english -- https://main.php.net/note/delete/127719/non-english Del: in docs -- https://main.php.net/note/delete/127719/in+docs Del: other reasons-- https://main.php.net/note/delete/127719 Reject -- https://main.php.net/note/reject/127719 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219669) next »