note 127565 added to function.strcmp
| From: | rjmacc45 at gmail dot com | Date: | Thu, 01 Sep 2022 16:04:15 +0000 |
| Subject: | note 127565 added to function.strcmp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219506@lists.php.net to get a copy of this message | ||
Actually jendo's comments about the values are not complete. It appears that when comparing
strings to NULL types, or values to NULL the returned number is the length of the string or number:
<?php
strcmp("foobar", NULL) => 8
strcmp(NULL, "foobar") => -8
strcmp("X", NULL) => 3
strcmp(NULL, "X") => -3
strcmp("foobarzoo", NULL) => 11
strcmp(NULL, "foobarzoo") => -11
strcmp(-3, NULL) => 2
strcmp(NULL, -3) => -2
strcmp(1123, NULL) => 4
strcmp(NULL, 1123) => -4
?>
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.173 (proxied: 87.115.84.96)
----
Manual Page -- https://php.net/manual/en/function.strcmp.php
Edit -- https://main.php.net/note/edit/127565
Del: integrated -- https://main.php.net/note/delete/127565/integrated
Del: useless -- https://main.php.net/note/delete/127565/useless
Del: bad code -- https://main.php.net/note/delete/127565/bad+code
Del: spam -- https://main.php.net/note/delete/127565/spam
Del: non-english -- https://main.php.net/note/delete/127565/non-english
Del: in docs -- https://main.php.net/note/delete/127565/in+docs
Del: other reasons-- https://main.php.net/note/delete/127565
Reject -- https://main.php.net/note/reject/127565
Search -- https://main.php.net/manage/user-notes.php