PageRenderTime 81ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 112 lines | 64 code | 24 blank | 24 comment | 0 complexity | 19b32122b5adf9fb6201dd3658a92fd1 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 seventh argument \$is_dst***\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 0' => 1,
  37. 'int 0' => -1,
  38. 'int 12345' => 12345,
  39. 'int -12345' => -12345,
  40. // float data
  41. 'float 10.5' => 10.5,
  42. 'float -10.5' => -10.5,
  43. 'float .5' => .5,
  44. // array data
  45. 'empty array' => array(),
  46. 'int indexed array' => $index_array,
  47. 'associative array' => $assoc_array,
  48. 'nested arrays' => array('foo', $index_array, $assoc_array),
  49. // null data
  50. 'uppercase NULL' => NULL,
  51. 'lowercase null' => null,
  52. // boolean data
  53. 'lowercase true' => true,
  54. 'lowercase false' =>false,
  55. 'uppercase TRUE' =>TRUE,
  56. 'uppercase FALSE' =>FALSE,
  57. // empty data
  58. 'empty string DQ' => "",
  59. 'empty string SQ' => '',
  60. // string data
  61. 'string DQ' => "string",
  62. 'string SQ' => 'string',
  63. 'mixed case string' => "sTrInG",
  64. 'heredoc' => $heredoc,
  65. // object data
  66. 'instance of classWithToString' => new classWithToString(),
  67. 'instance of classWithoutToString' => new classWithoutToString(),
  68. // undefined data
  69. 'undefined var' => @$undefined_var,
  70. // unset data
  71. 'unset var' => @$unset_var,
  72. // resource
  73. 'resource' => $file_handle
  74. );
  75. $hour = 10;
  76. $minute = 30;
  77. $second = 45;
  78. $month = 7;
  79. $day = 2;
  80. $year = 1963;
  81. foreach($inputs as $variation =>$is_dst) {
  82. echo "\n-- $variation --\n";
  83. var_dump( mktime($hour, $minute, $second, $month, $day, $year, $is_dst) );
  84. };
  85. // closing the resource
  86. fclose( $file_handle );
  87. ?>
  88. ===DONE===