note 129108 added to language.types.null

From: Date: Sat, 16 Dec 2023 12:03:44 +0000
Subject: note 129108 added to language.types.null
Groups: php.notes 
Request: Send a blank email to php-notes+get-221062@lists.php.net to get a copy of this message
<?php // Note : Empty strings and arrays return true when compared to null using the non-strict equality operator == . var_export( [] == null ); // <== return true echo "\n"; var_export( "" == null ); // <== return true echo "\n"; // the correct way is to use strict equal === echo ( [] === null); echo "\n"; echo ( "" === null); echo "\n"; /* Alternatively, the is_null() function can be used to explicitly check if a value is null. In this case, is_null("") and is_null([]) will both return false. */ echo (is_null("")); echo "\n"; echo (is_null([])); echo "\n"; ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 196.115.70.223) ---- Manual Page -- https://php.net/manual/en/language.types.null.php Edit -- https://main.php.net/note/edit/129108 Del: integrated -- https://main.php.net/note/delete/129108/integrated Del: useless -- https://main.php.net/note/delete/129108/useless Del: bad code -- https://main.php.net/note/delete/129108/bad+code Del: spam -- https://main.php.net/note/delete/129108/spam Del: non-english -- https://main.php.net/note/delete/129108/non-english Del: in docs -- https://main.php.net/note/delete/129108/in+docs Del: other reasons-- https://main.php.net/note/delete/129108 Reject -- https://main.php.net/note/reject/129108 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221062) next »