PageRenderTime 107ms CodeModel.GetById 22ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 49 lines | 32 code | 11 blank | 6 comment | 2 complexity | 99878c13b276cd9ea445433ca2446814 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. /* Testing for Error conditions */
  3. /* Invalid Number of Arguments */
  4. echo "\n *** Output for Error Conditions ***\n";
  5. rtrim();
  6. rtrim("", " ", 1);
  7. /* Testing the Normal behaviour of rtrim() function */
  8. echo "\n *** Output for Normal Behaviour ***\n";
  9. var_dump ( rtrim("rtrim test \t\0 ") ); /* without second Argument */
  10. var_dump ( rtrim("rtrim test " , "") ); /* no characters in second Argument */
  11. var_dump ( rtrim("rtrim test ", NULL) ); /* with NULL as second Argument */
  12. var_dump ( rtrim("rtrim test ", true) ); /* with boolean value as second Argument */
  13. var_dump ( rtrim("rtrim test ", " ") ); /* with single space as second Argument */
  14. var_dump ( rtrim("rtrim test \t\n\r\0\x0B", "\t\n\r\0\x0B") ); /* with multiple escape sequences as second Argument */
  15. var_dump ( rtrim("rtrim testABCXYZ", "A..Z") ); /* with characters range as second Argument */
  16. var_dump ( rtrim("rtrim test0123456789", "0..9") ); /* with numbers range as second Argument */
  17. var_dump ( rtrim("rtrim test$#@", "#@$") ); /* with some special characters as second Argument */
  18. /* Use of class and objects */
  19. echo "\n*** Checking with OBJECTS ***\n";
  20. class string1 {
  21. public function __toString() {
  22. return "Object";
  23. }
  24. }
  25. $obj = new string1;
  26. var_dump( rtrim($obj, "tc") );
  27. /* String with embedded NULL */
  28. echo "\n*** String with embedded NULL ***\n";
  29. var_dump( rtrim("234\x0005678\x0000efgh\xijkl\x0n1", "\x0n1") );
  30. /* heredoc string */
  31. $str = <<<EOD
  32. us
  33. ing heredoc string
  34. EOD;
  35. echo "\n *** Using heredoc string ***\n";
  36. var_dump( rtrim($str, "ing") );
  37. echo "Done\n";
  38. ?>