note 118102 added to function.strcmp

From: Date: Sun, 04 Oct 2015 22:01:52 +0000
Subject: note 118102 added to function.strcmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-203904@lists.php.net to get a copy of this message
strcmp returns -1 ou 1 if two strings are not identical, and 0 when they are, except when comparing a string and an empty string (<?php $a = ""; ?>), it returns the length of the string. For instance: <?php $a = "foo"; // length 3 $b = ""; // empty string $c = "barbar"; // length 6 echo strcmp($a, $a); // outputs 0 echo strcmp($a, $c); // outputs 1 echo strcmp($c, $a); // outputs -1 echo strcmp($a, $b); // outputs 3 echo strcmp($b, $a); // outputs -3 echo strcmp($c, $b); // outputs 6 echo strcmp($b, $c); // outputs -6 ?> ---- Server IP: 72.52.91.14 Probable Submitter: 2804:14d:7e8b:1e3:c92f:bd63:fb65:714a ---- Manual Page -- http://php.net/manual/en/function.strcmp.php Edit -- https://master.php.net/note/edit/118102 Del: integrated -- https://master.php.net/note/delete/118102/integrated Del: useless -- https://master.php.net/note/delete/118102/useless Del: bad code -- https://master.php.net/note/delete/118102/bad+code Del: spam -- https://master.php.net/note/delete/118102/spam Del: non-english -- https://master.php.net/note/delete/118102/non-english Del: in docs -- https://master.php.net/note/delete/118102/in+docs Del: other reasons-- https://master.php.net/note/delete/118102 Reject -- https://master.php.net/note/reject/118102 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203904) next »