stripos_basic2.phpt 1.4 KB

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