strrpos_basic2.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Test strrpos() function : basic functionality - with all arguments
  3. --FILE--
  4. <?php
  5. /* Prototype : int strrpos ( string $haystack, string $needle [, int $offset] );
  6. * Description: Find position of last occurrence of 'needle' in 'haystack'
  7. * Source code: ext/standard/string.c
  8. */
  9. echo "*** Testing strrpos() function: basic functionality ***\n";
  10. $heredoc_str = <<<EOD
  11. Hello, World
  12. EOD;
  13. echo "-- With all arguments --\n";
  14. //regular string for haystack & needle, with various offsets
  15. var_dump( strrpos("Hello, World", "Hello", 0) );
  16. var_dump( strrpos("Hello, World", 'Hello', 1) );
  17. var_dump( strrpos('Hello, World', 'World', 1) );
  18. var_dump( strrpos('Hello, World', "World", 5) );
  19. //heredoc string for haystack & needle, with various offsets
  20. var_dump( strrpos($heredoc_str, "Hello, World", 0) );
  21. var_dump( strrpos($heredoc_str, 'Hello', 0) );
  22. var_dump( strrpos($heredoc_str, 'Hello', 1) );
  23. var_dump( strrpos($heredoc_str, $heredoc_str, 0) );
  24. var_dump( strrpos($heredoc_str, $heredoc_str, 1) );
  25. //various offsets
  26. var_dump( strrpos("Hello, World", "o", 3) );
  27. var_dump( strrpos("Hello, World", "o", 6) );
  28. var_dump( strrpos("Hello, World", "o", 10) );
  29. echo "*** Done ***";
  30. ?>
  31. --EXPECTF--
  32. *** Testing strrpos() function: basic functionality ***
  33. -- With all arguments --
  34. int(0)
  35. bool(false)
  36. int(7)
  37. int(7)
  38. int(0)
  39. int(0)
  40. bool(false)
  41. int(0)
  42. bool(false)
  43. int(8)
  44. int(8)
  45. bool(false)
  46. *** Done ***