strncasecmp_variation7.phpt 728 B

12345678910111213141516171819202122
  1. --TEST--
  2. Test strncasecmp() function : usage variations - binary safe
  3. --FILE--
  4. <?php
  5. /* Test strncasecmp() function with null terminated strings and binary values passed to 'str1' & 'str2' */
  6. echo "*** Test strncasecmp() function: with null terminated strings and binary inputs ***\n";
  7. /* A binary function should not expect a null terminated string, and it should treat input as a raw stream of data */
  8. $str1 = "Hello\0world";
  9. $str2 = "Hello\0";
  10. $str3 = "Hello,".chr(0)."world";
  11. var_dump( strncasecmp($str1, $str2, 12) );
  12. var_dump( strncasecmp($str3, "Hello,world", 12) );
  13. echo "*** Done ***\n";
  14. ?>
  15. --EXPECT--
  16. *** Test strncasecmp() function: with null terminated strings and binary inputs ***
  17. int(5)
  18. int(-119)
  19. *** Done ***