strripos_basic2.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test strripos() function : basic functionality - with all arguments
  3. --FILE--
  4. <?php
  5. echo "*** Testing strripos() function: basic functionality ***\n";
  6. $heredoc_str = <<<EOD
  7. Hello, World
  8. EOD;
  9. echo "\n-- regular string for haystack & needle, with various offsets --\n";
  10. var_dump( strripos("Hello, World", "HeLLo", 0) );
  11. var_dump( strripos("Hello, World", 'Hello', 1) );
  12. var_dump( strripos('Hello, World', 'world', 1) );
  13. var_dump( strripos('Hello, World', "WorLD", 5) );
  14. echo "\n-- heredoc string for haystack & needle, with various offsets --\n";
  15. var_dump( strripos($heredoc_str, "Hello, WORLD", 0) );
  16. var_dump( strripos($heredoc_str, 'HelLo', 0) );
  17. var_dump( strripos($heredoc_str, 'HeLLo', 1) );
  18. var_dump( strripos($heredoc_str, $heredoc_str, 0) );
  19. var_dump( strripos($heredoc_str, $heredoc_str, 1) );
  20. echo "\n-- various +ve offsets --\n";
  21. var_dump( strripos("Hello, World", "O", 3) );
  22. var_dump( strripos("Hello, World", "O", 6) );
  23. var_dump( strripos("Hello, World", "O", 10) );
  24. echo "\n-- various -ve offsets --\n";
  25. var_dump( strripos("Hello, World", "O", -1) );
  26. var_dump( strripos("Hello, World", "O", -5) );
  27. var_dump( strripos("Hello, World", "O", -9) );
  28. ?>
  29. --EXPECT--
  30. *** Testing strripos() function: basic functionality ***
  31. -- regular string for haystack & needle, with various offsets --
  32. int(0)
  33. bool(false)
  34. int(7)
  35. int(7)
  36. -- heredoc string for haystack & needle, with various offsets --
  37. int(0)
  38. int(0)
  39. bool(false)
  40. int(0)
  41. bool(false)
  42. -- various +ve offsets --
  43. int(8)
  44. int(8)
  45. bool(false)
  46. -- various -ve offsets --
  47. int(8)
  48. int(4)
  49. bool(false)