strncmp_variation7.phpt 659 B

12345678910111213141516171819
  1. --TEST--
  2. Test strncmp() function : usage variations - binary safe(null terminated strings)
  3. --FILE--
  4. <?php
  5. /* Test strncmp() function with binary values passed to 'str1' & 'str2' and with the null terminated strings */
  6. echo "*** Test strncmp() function: Checking with the null terminated strings ***\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. var_dump( strncmp($str1, $str2, 12) ); //expected: int(5);
  11. echo "*** Done ***\n";
  12. ?>
  13. --EXPECT--
  14. *** Test strncmp() function: Checking with the null terminated strings ***
  15. int(5)
  16. *** Done ***