strncmp_variation9.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Test strncmp() function: usage variations - different inputs(heredoc strings)
  3. --FILE--
  4. <?php
  5. /* Test strncmp() function with different strings for 'str1', 'str2' and considering case sensitive */
  6. echo "*** Test strncmp() function: with different input strings ***\n";
  7. /* heredoc string */
  8. $str1 = <<<EOD
  9. Example of string
  10. spanning multiple lines
  11. using heredoc syntax.
  12. EOD;
  13. /* identifier name contains underscore */
  14. $str2 = <<<identifier_str2
  15. Example of heredoc
  16. string, whose identifier
  17. having underscore("_")
  18. & numeric value.
  19. identifier_str2;
  20. /* identifier name starts with underscore */
  21. $str3 = <<<_identifier_str3
  22. Hello, World
  23. hello, world
  24. _identifier_str3;
  25. /* string containing control characters */
  26. $str4 = <<<identifier_str4
  27. Hello, World\n
  28. Hello\0World
  29. identifier_str4;
  30. $strings = array(
  31. $str1,
  32. $str2,
  33. $str3,
  34. $str4
  35. );
  36. /* loop through to compare each string with the other string */
  37. $count = 1;
  38. for($index1 = 0; $index1 < count($strings); $index1++) {
  39. var_dump( strncmp( $strings[$index1], $strings[$index1], strlen($strings[$index1]) ) );
  40. $count ++;
  41. }
  42. echo "*** Done ***\n";
  43. ?>
  44. --EXPECT--
  45. *** Test strncmp() function: with different input strings ***
  46. int(0)
  47. int(0)
  48. int(0)
  49. int(0)
  50. *** Done ***