strncasecmp_variation9.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --TEST--
  2. Test strncasecmp() function: usage variations - heredoc strings
  3. --FILE--
  4. <?php
  5. /* Test strncasecmp() function with here-doc strings for 'str1', 'str2' */
  6. echo "*** Test strncasecmp() function: with here-doc strings ***\n";
  7. /* multi line heredoc string */
  8. $multi_line_str = <<<EOD
  9. Example of string
  10. spanning multiple lines
  11. using heredoc syntax.
  12. EOD;
  13. /* identifier name contains underscore */
  14. $identifier_str1 = <<<identifier_str1
  15. Example of heredoc
  16. string, whose identifier
  17. having underscore("_")
  18. & numeric value.
  19. identifier_str1;
  20. /* identifier name starts with underscore */
  21. $identifier_str2 = <<<_identifier_str2
  22. Hello, World
  23. hello, world
  24. _identifier_str2;
  25. /* string containing control character */
  26. $control_char_str = <<<EOD
  27. Hello, World\n
  28. Hello\0World
  29. EOD;
  30. /* heredoc string with quote chars & slash */
  31. $quote_char_string = <<<EOD
  32. it's bright,but i cann't see it.
  33. "things in double quote"
  34. 'things in single quote'
  35. this\line is /with\slashs
  36. EOD;
  37. /* heredoc string with blank line */
  38. $blank_line = <<<EOD
  39. EOD;
  40. /* empty heredoc string */
  41. $empty_string = <<<EOD
  42. EOD;
  43. $strings = array(
  44. $multi_line_str,
  45. $identifier_str1,
  46. $identifier_str2,
  47. $control_char_str,
  48. $quote_char_string,
  49. $blank_line,
  50. $empty_string
  51. );
  52. /* loop through to compare the strings */
  53. $index2 = count($strings);
  54. for($index1 = 0; $index1 < count($strings); $index1++) {
  55. $index2--;
  56. var_dump( strncasecmp( $strings[$index1], $strings[$index1], strlen($strings[$index1]) ) );
  57. var_dump( strncasecmp( $strings[$index1], $strings[$index2], strlen($strings[$index1]) ) );
  58. }
  59. echo "*** Done ***\n";
  60. ?>
  61. --EXPECT--
  62. *** Test strncasecmp() function: with here-doc strings ***
  63. int(0)
  64. int(63)
  65. int(0)
  66. int(83)
  67. int(0)
  68. int(-1)
  69. int(0)
  70. int(0)
  71. int(0)
  72. int(1)
  73. int(0)
  74. int(0)
  75. int(0)
  76. int(0)
  77. *** Done ***