PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 37 lines | 24 code | 5 blank | 8 comment | 0 complexity | 5d6a10ad5552edd16404238f270cdce7 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 special chars for haystack
  7. * and with various needles
  8. */
  9. echo "*** Testing strrchr() function: with heredoc strings ***\n";
  10. $special_chars_str = <<<EOD
  11. Example of heredoc string contains
  12. $#%^*&*_("_")!#@@!$#$^^&*(special)
  13. chars.
  14. EOD;
  15. $heredoc_needle = <<<EOD
  16. ^^&*(
  17. EOD;
  18. $needles = array(
  19. "!@@!",
  20. '_',
  21. '("_")',
  22. "$*",
  23. "(special)",
  24. $heredoc_needle, //needle as heredoc string
  25. $special_chars_str //needle as haystack
  26. );
  27. //loop through to test strrchr() with each needle
  28. foreach($needles as $needle) {
  29. var_dump( strrchr($special_chars_str, $needle) );
  30. }
  31. echo "*** Done ***";
  32. ?>