PageRenderTime 78ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 98 lines | 57 code | 20 blank | 21 comment | 0 complexity | 673bc21e00cc6a9f07931e74c1ee1b92 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 : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
  3. * Description: Returns time of sunrise for a given day and location
  4. * Source code: ext/date/php_date.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing date_sunrise() : usage variation ***\n";
  8. // Initialise function arguments not being substituted (if any)
  9. date_default_timezone_set("Asia/Calcutta");
  10. $time = mktime(8, 8, 8, 8, 8, 2008);
  11. $latitude = 38.4;
  12. $longitude = -9;
  13. $gmt_offset = 5.5;
  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. // int data
  37. 'int 0' => 0,
  38. 'int 1' => 1,
  39. 'int 12345' => 12345,
  40. 'int -12345' => -12345,
  41. // array data
  42. 'empty array' => array(),
  43. 'int indexed array' => $index_array,
  44. 'associative array' => $assoc_array,
  45. 'nested arrays' => array('foo', $index_array, $assoc_array),
  46. // null data
  47. 'uppercase NULL' => NULL,
  48. 'lowercase null' => null,
  49. // boolean data
  50. 'lowercase true' => true,
  51. 'lowercase false' =>false,
  52. 'uppercase TRUE' =>TRUE,
  53. 'uppercase FALSE' =>FALSE,
  54. // empty data
  55. 'empty string DQ' => "",
  56. 'empty string SQ' => '',
  57. // string data
  58. 'string DQ' => "string",
  59. 'string SQ' => 'string',
  60. 'mixed case string' => "sTrInG",
  61. 'heredoc' => $heredoc,
  62. // object data
  63. 'instance of classWithToString' => new classWithToString(),
  64. 'instance of classWithoutToString' => new classWithoutToString(),
  65. // undefined data
  66. 'undefined var' => @$undefined_var,
  67. // unset data
  68. 'unset var' => @$unset_var,
  69. );
  70. // loop through each element of the array for zenith
  71. foreach($inputs as $key =>$value) {
  72. echo "\n--$key--\n";
  73. var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $value, $gmt_offset) );
  74. var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $value, $gmt_offset) );
  75. var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $value, $gmt_offset) );
  76. };
  77. ?>
  78. ===DONE===