PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 79 lines | 42 code | 19 blank | 18 comment | 1 complexity | 477300d0dbc4930e88d00b5389d9d799 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 stristr ( string $haystack, string $needle );
  3. Description: Case-insensitive strstr().
  4. */
  5. echo "*** Testing stristr() function: with unexpected inputs for 'string' argument ***\n";
  6. //get an unset variable
  7. $unset_var = 'string_val';
  8. unset($unset_var);
  9. //defining a class
  10. class sample {
  11. public function __toString() {
  12. return "sample object";
  13. }
  14. }
  15. //getting the resource
  16. $file_handle = fopen(__FILE__, "r");
  17. // array with different values for $input
  18. $inputs = array (
  19. // integer values
  20. /*1*/ 0,
  21. 1,
  22. -2,
  23. -PHP_INT_MAX,
  24. // float values
  25. /*5*/ 10.5,
  26. -20.5,
  27. 10.1234567e10,
  28. // array values
  29. /*8*/ array(),
  30. array(0),
  31. array(1, 2),
  32. // boolean values
  33. /*11*/ true,
  34. false,
  35. TRUE,
  36. FALSE,
  37. // null vlaues
  38. /*15*/ NULL,
  39. null,
  40. // objects
  41. /*17*/ new sample(),
  42. // resource
  43. /*18*/ $file_handle,
  44. // undefined variable
  45. /*19*/ @$undefined_var,
  46. // unset variable
  47. /*20*/ @$unset_var
  48. );
  49. //defining '$pad_length' argument
  50. $pad_length = "20";
  51. // loop through with each element of the $inputs array to test stristr() function
  52. $count = 1;
  53. foreach($inputs as $input) {
  54. echo "-- Iteration $count --\n";
  55. var_dump( stristr($input, " ") );
  56. $count ++;
  57. }
  58. fclose($file_handle); //closing the file handle
  59. ?>
  60. ===DONE===