PageRenderTime 34ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 95 lines | 54 code | 20 blank | 21 comment | 0 complexity | bbf46a46495fb4524c472e3be118a090 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 gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
  3. * Description: Get UNIX timestamp for a GMT date
  4. * Source code: ext/date/php_date.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing gmmktime() : usage variation ***\n";
  8. // Initialise function arguments not being substituted (if any)
  9. $min = 8;
  10. $sec = 8;
  11. $mon = 8;
  12. $day = 8;
  13. $year = 2008;
  14. //get an unset variable
  15. $unset_var = 10;
  16. unset ($unset_var);
  17. // define some classes
  18. class classWithToString
  19. {
  20. public function __toString() {
  21. return "Class A object";
  22. }
  23. }
  24. class classWithoutToString
  25. {
  26. }
  27. // heredoc string
  28. $heredoc = <<<EOT
  29. hello world
  30. EOT;
  31. // add arrays
  32. $index_array = array (1, 2, 3);
  33. $assoc_array = array ('one' => 1, 'two' => 2);
  34. //array of values to iterate over
  35. $inputs = array(
  36. // float data
  37. 'float 10.5' => 10.5,
  38. 'float -10.5' => -10.5,
  39. 'float .5' => .5,
  40. // array data
  41. 'empty array' => array(),
  42. 'int indexed array' => $index_array,
  43. 'associative array' => $assoc_array,
  44. 'nested arrays' => array('foo', $index_array, $assoc_array),
  45. // null data
  46. 'uppercase NULL' => NULL,
  47. 'lowercase null' => null,
  48. // boolean data
  49. 'lowercase true' => true,
  50. 'lowercase false' =>false,
  51. 'uppercase TRUE' =>TRUE,
  52. 'uppercase FALSE' =>FALSE,
  53. // empty data
  54. 'empty string DQ' => "",
  55. 'empty string SQ' => '',
  56. // string data
  57. 'string DQ' => "string",
  58. 'string SQ' => 'string',
  59. 'mixed case string' => "sTrInG",
  60. 'heredoc' => $heredoc,
  61. // object data
  62. 'instance of classWithToString' => new classWithToString(),
  63. 'instance of classWithoutToString' => new classWithoutToString(),
  64. // undefined data
  65. 'undefined var' => @$undefined_var,
  66. // unset data
  67. 'unset var' => @$unset_var,
  68. );
  69. // loop through each element of the array for hour
  70. foreach($inputs as $key =>$value) {
  71. echo "\n--$key--\n";
  72. var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) );
  73. };
  74. ?>
  75. ===DONE===