note 20816 added to function.strncmp
| From: | Anonymous at php2 dot chek dot com | Date: | Wed, 17 Apr 2002 08:46:15 +0000 |
| Subject: | note 20816 added to function.strncmp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29464@lists.php.net to get a copy of this message | ||
strncmp("sample","sam",4) returns 1 because the final requirement is if one
string terminates before len, then the other must also terminate at that position.
You can imagine that all your strings have one more final, invisible "termination"
character. If that termination character happens to be within in len, then it must match, too.
For instance, write that termination character with, say, the sequence "\0". Then you can
equivalently consider that function call as strncmp("sample\0","sam\0",4).
So, the "p" in "sample" does not match the termination character in
"sam".
--
http://www.php.net/manual/en/function.strncmp.php
http://master.php.net/manage/user-notes.php?action=edit+20816
http://master.php.net/manage/user-notes.php?action=delete+20816
http://master.php.net/manage/user-notes.php?action=reject+20816