mb_strrpos_variation5.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. --TEST--
  2. Test mb_strrpos() function : usage variations - pass encoding as third argument (deprecated behaviour)
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_strrpos') or die("skip mb_strrpos() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : int mb_strrpos(string $haystack, string $needle [, int $offset [, string $encoding]])
  11. * Description: Find position of last occurrence of a string within another
  12. * Source code: ext/mbstring/mbstring.c
  13. */
  14. /*
  15. * Testing deprecated behaviour where third argument can be $encoding
  16. */
  17. echo "*** Testing mb_strrpos() : usage variations ***\n";
  18. $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
  19. $needle_mb = base64_decode('44CC');
  20. $stringh = <<<END
  21. utf-8
  22. END;
  23. $inputs = array('Double Quoted String' => "utf-8",
  24. 'Single Quoted String' => 'utf-8',
  25. 'Heredoc' => $stringh);
  26. foreach ($inputs as $type => $input) {
  27. echo "\n-- $type --\n";
  28. echo "-- With fourth encoding argument --\n";
  29. var_dump(mb_strrpos($string_mb, $needle_mb, $input, 'utf-8'));
  30. echo "-- Without fourth encoding argument --\n";
  31. var_dump(mb_strrpos($string_mb, $needle_mb, $input));
  32. }
  33. echo "Done";
  34. ?>
  35. --EXPECTF--
  36. *** Testing mb_strrpos() : usage variations ***
  37. -- Double Quoted String --
  38. -- With fourth encoding argument --
  39. int(20)
  40. -- Without fourth encoding argument --
  41. int(20)
  42. -- Single Quoted String --
  43. -- With fourth encoding argument --
  44. int(20)
  45. -- Without fourth encoding argument --
  46. int(20)
  47. -- Heredoc --
  48. -- With fourth encoding argument --
  49. int(20)
  50. -- Without fourth encoding argument --
  51. int(20)
  52. Done