PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/zend/good/ext/standard/tests/strings/strrchr_variation7.php

http://github.com/facebook/hiphop-php
PHP | 31 lines | 19 code | 4 blank | 8 comment | 0 complexity | c64bd621371cccf57e827a3d6679c32e 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. <?hh
  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. * blank-line for haystack and with various needles
  8. */
  9. <<__EntryPoint>> function main(): void {
  10. echo "*** Testing strrchr() function: with heredoc strings ***\n";
  11. $blank_line = <<<EOD
  12. EOD;
  13. $needles = varray[
  14. "\n",
  15. '\n',
  16. "\r",
  17. "\r\n",
  18. "\t",
  19. "",
  20. $blank_line //needle as haystack
  21. ];
  22. //loop through to test strrchr() with each needle
  23. foreach($needles as $needle) {
  24. var_dump( strrchr($blank_line, $needle) );
  25. }
  26. echo "*** Done ***";
  27. }