PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/date/tests/mktime_variation2.php

http://github.com/facebook/hiphop-php
PHP | 105 lines | 57 code | 24 blank | 24 comment | 0 complexity | 70ea492018b93f68b787ce332b5a850d 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 : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
  3. * Description: Get Unix timestamp for a date
  4. * Source code: ext/date/php_date.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing mktime() : usage variation - unexpected values to second argument \$minute***\n";
  8. //Set the default time zone
  9. date_default_timezone_set("Europe/London");
  10. //get an unset variable
  11. $unset_var = 10;
  12. unset ($unset_var);
  13. // define some classes
  14. class classWithToString
  15. {
  16. public function __toString() {
  17. return "Class A object";
  18. }
  19. }
  20. class classWithoutToString
  21. {
  22. }
  23. // heredoc string
  24. $heredoc = <<<EOT
  25. hello world
  26. EOT;
  27. // add arrays
  28. $index_array = array (1, 2, 3);
  29. $assoc_array = array ('one' => 1, 'two' => 2);
  30. // resource
  31. $file_handle = fopen(__FILE__, 'r');
  32. //array of values to iterate over
  33. $inputs = array(
  34. // int data
  35. 'int 0' => 0,
  36. 'int 12345' => 12345,
  37. 'int -12345' => -12345,
  38. // float data
  39. 'float 10.5' => 10.5,
  40. 'float -10.5' => -10.5,
  41. 'float .5' => .5,
  42. // array data
  43. 'empty array' => array(),
  44. 'int indexed array' => $index_array,
  45. 'associative array' => $assoc_array,
  46. 'nested arrays' => array('foo', $index_array, $assoc_array),
  47. // null data
  48. 'uppercase NULL' => NULL,
  49. 'lowercase null' => null,
  50. // boolean data
  51. 'lowercase true' => true,
  52. 'lowercase false' =>false,
  53. 'uppercase TRUE' =>TRUE,
  54. 'uppercase FALSE' =>FALSE,
  55. // empty data
  56. 'empty string DQ' => "",
  57. 'empty string SQ' => '',
  58. // string data
  59. 'string DQ' => "string",
  60. 'string SQ' => 'string',
  61. 'mixed case string' => "sTrInG",
  62. 'heredoc' => $heredoc,
  63. // object data
  64. 'instance of classWithToString' => new classWithToString(),
  65. 'instance of classWithoutToString' => new classWithoutToString(),
  66. // undefined data
  67. 'undefined var' => @$undefined_var,
  68. // unset data
  69. 'unset var' => @$unset_var,
  70. // resource
  71. 'resource' => $file_handle
  72. );
  73. $hour = 10;
  74. foreach($inputs as $variation =>$minute) {
  75. echo "\n-- $variation --\n";
  76. var_dump( mktime($hour, $minute) );
  77. };
  78. // closing the resource
  79. fclose( $file_handle );
  80. ?>
  81. ===DONE===