stripos_basic2.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --TEST--
  2. Test stripos() function : basic functionality - with all arguments
  3. --FILE--
  4. <?php
  5. echo "*** Testing stripos() function: basic functionality ***\n";
  6. $heredoc_str = <<<Identifier
  7. Hello, World
  8. Identifier;
  9. echo "-- With all arguments --\n";
  10. //regular string for haystack & needle, with various offsets
  11. var_dump( stripos("Hello, World", "Hello", 0) );
  12. var_dump( stripos("Hello, World", 'Hello', 1) );
  13. var_dump( stripos('Hello, World', 'WORLD', 1) );
  14. var_dump( stripos('Hello, World', "WoRld", 5) );
  15. var_dump( stripos('Hello, World', "WoRld", -6) );
  16. var_dump( stripos('Hello, World', "WoRld", -3) );
  17. var_dump( stripos('Hello, World', "WoRld", -12) );
  18. //heredoc string for haystack & needle, with various offsets
  19. var_dump( stripos($heredoc_str, "Hello, World", 0) );
  20. var_dump( stripos($heredoc_str, 'Hello', 0) );
  21. var_dump( stripos($heredoc_str, 'Hello', 1) );
  22. var_dump( stripos($heredoc_str, $heredoc_str, 0) );
  23. var_dump( stripos($heredoc_str, $heredoc_str, 1) );
  24. var_dump( stripos($heredoc_str, $heredoc_str, -strlen($heredoc_str)) );
  25. var_dump( stripos($heredoc_str, $heredoc_str, -strlen($heredoc_str)+1) );
  26. //various offsets
  27. var_dump( stripos("Hello, World", "o", 3) );
  28. var_dump( stripos("Hello, World", "O", 5) );
  29. var_dump( stripos("Hello, World", "o", 6) );
  30. var_dump( stripos("Hello, World", "o", 10) );
  31. var_dump( stripos("Hello, World", "o", -7) );
  32. var_dump( stripos("Hello, World", "o", -8) );
  33. var_dump( stripos("Hello, World", "o", -10) );
  34. var_dump( stripos("Hello, World", "o", -4) );
  35. var_dump( stripos("Hello, World", "o", -3) );
  36. echo "*** Done ***";
  37. ?>
  38. --EXPECT--
  39. *** Testing stripos() function: basic functionality ***
  40. -- With all arguments --
  41. int(0)
  42. bool(false)
  43. int(7)
  44. int(7)
  45. int(7)
  46. bool(false)
  47. int(7)
  48. int(0)
  49. int(0)
  50. bool(false)
  51. int(0)
  52. bool(false)
  53. int(0)
  54. bool(false)
  55. int(4)
  56. int(8)
  57. int(8)
  58. bool(false)
  59. int(8)
  60. int(4)
  61. int(4)
  62. int(8)
  63. bool(false)
  64. *** Done ***