strripos_basic1.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Test strripos() function : basic functionality - with default arguments
  3. --FILE--
  4. <?php
  5. /* Prototype : int strripos ( string $haystack, string $needle [, int $offset] );
  6. * Description: Find position of last occurrence of a case-insensitive 'needle' in a 'haystack'
  7. * Source code: ext/standard/string.c
  8. */
  9. echo "*** Testing strripos() function: basic functionality ***\n";
  10. $heredoc_str = <<<EOD
  11. Hello, World
  12. EOD;
  13. echo "\n-- regular string for haystack & needle --\n";
  14. var_dump( strripos("Hello, World", "HeLLo") );
  15. var_dump( strripos('Hello, World', "hello") );
  16. var_dump( strripos("Hello, World", 'WoRLd') );
  17. var_dump( strripos('Hello, World', 'WORLD') );
  18. var_dump( strripos('Hello, World', 'foo') );
  19. echo "\n-- single char for needle --\n";
  20. var_dump( strripos("Hello, World", "O") );
  21. var_dump( strripos("Hello, World", ",") );
  22. echo "\n-- heredoc string for haystack & needle --\n";
  23. var_dump( strripos($heredoc_str, "Hello, WoRLd") );
  24. var_dump( strripos($heredoc_str, 'HelLO') );
  25. var_dump( strripos($heredoc_str, $heredoc_str) );
  26. ?>
  27. ===DONE===
  28. --EXPECT--
  29. *** Testing strripos() function: basic functionality ***
  30. -- regular string for haystack & needle --
  31. int(0)
  32. int(0)
  33. int(7)
  34. int(7)
  35. bool(false)
  36. -- single char for needle --
  37. int(8)
  38. int(5)
  39. -- heredoc string for haystack & needle --
  40. int(0)
  41. int(0)
  42. int(0)
  43. ===DONE===