note 128922 added to function.stripos
| From: | mirko at main dot php dot net | Date: | Thu, 28 Sep 2023 13:44:02 +0000 |
| Subject: | note 128922 added to function.stripos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220881@lists.php.net to get a copy of this message | ||
It looks like from php 8 putting 'false' as needle return value would be '0' -
i.e. result will be true.
For example:
<?php
echo stripos('abcdef', false);
?>
/*output will be true:
0
*/
Be careful when setting $foo to false because:
<?php
if(stripos('abcdef', $foo)):
// this will be true
endif;
?>
So, although $foo was set to false stripos return value was numeric (0) - true - like the needle was
found in the haystack at the first position.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 213.147.118.153)
----
Manual Page -- https://php.net/manual/en/function.stripos.php
Edit -- https://main.php.net/note/edit/128922
Del: integrated -- https://main.php.net/note/delete/128922/integrated
Del: useless -- https://main.php.net/note/delete/128922/useless
Del: bad code -- https://main.php.net/note/delete/128922/bad+code
Del: spam -- https://main.php.net/note/delete/128922/spam
Del: non-english -- https://main.php.net/note/delete/128922/non-english
Del: in docs -- https://main.php.net/note/delete/128922/in+docs
Del: other reasons-- https://main.php.net/note/delete/128922
Reject -- https://main.php.net/note/reject/128922
Search -- https://main.php.net/manage/user-notes.php