strrpos_basic2.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Test strrpos() function : basic functionality - with all arguments
  3. --FILE--
  4. <?php
  5. echo "*** Testing strrpos() function: basic functionality ***\n";
  6. $heredoc_str = <<<EOD
  7. Hello, World
  8. EOD;
  9. echo "-- With all arguments --\n";
  10. //regular string for haystack & needle, with various offsets
  11. var_dump( strrpos("Hello, World", "Hello", 0) );
  12. var_dump( strrpos("Hello, World", 'Hello', 1) );
  13. var_dump( strrpos('Hello, World', 'World', 1) );
  14. var_dump( strrpos('Hello, World', "World", 5) );
  15. //heredoc string for haystack & needle, with various offsets
  16. var_dump( strrpos($heredoc_str, "Hello, World", 0) );
  17. var_dump( strrpos($heredoc_str, 'Hello', 0) );
  18. var_dump( strrpos($heredoc_str, 'Hello', 1) );
  19. var_dump( strrpos($heredoc_str, $heredoc_str, 0) );
  20. var_dump( strrpos($heredoc_str, $heredoc_str, 1) );
  21. //various offsets
  22. var_dump( strrpos("Hello, World", "o", 3) );
  23. var_dump( strrpos("Hello, World", "o", 6) );
  24. var_dump( strrpos("Hello, World", "o", 10) );
  25. echo "*** Done ***";
  26. ?>
  27. --EXPECT--
  28. *** Testing strrpos() function: basic functionality ***
  29. -- With all arguments --
  30. int(0)
  31. bool(false)
  32. int(7)
  33. int(7)
  34. int(0)
  35. int(0)
  36. bool(false)
  37. int(0)
  38. bool(false)
  39. int(8)
  40. int(8)
  41. bool(false)
  42. *** Done ***