PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/standard/tests/strings/strrchr_variation5.php

http://github.com/facebook/hiphop-php
PHP | 31 lines | 18 code | 5 blank | 8 comment | 0 complexity | 4a33ac8b2b6213f503602d01a180792b MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /* Prototype : string strrchr(string $haystack, string $needle);
  3. * Description: Finds the last occurrence of a character in a string.
  4. * Source code: ext/standard/string.c
  5. */
  6. /* Test strrchr() function by passing heredoc string containing
  7. * escape sequences for haystack and with various needles
  8. */
  9. echo "*** Testing strrchr() function: with heredoc strings ***\n";
  10. $escape_char_str = <<<EOD
  11. \tes\t st\r\rch\r using
  12. \escape \\seque\nce
  13. EOD;
  14. $needles = array(
  15. "\t",
  16. '\n',
  17. "\r",
  18. "\\",
  19. $escape_char_str //needle as haystack
  20. );
  21. //loop through to test strrchr() with each needle
  22. foreach($needles as $needle) {
  23. var_dump( strrchr($escape_char_str, $needle) );
  24. }
  25. echo "*** Done ***";
  26. ?>