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

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

http://github.com/facebook/hiphop-php
PHP | 99 lines | 55 code | 22 blank | 22 comment | 0 complexity | d3462ae0b44d973af376dbd598891e72 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 gmdate(string format [, long timestamp])
  3. * Description: Format a GMT date/time
  4. * Source code: ext/date/php_date.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing gmdate() : usage variation ***\n";
  8. // Initialise all required variables
  9. date_default_timezone_set('UTC');
  10. $format = DATE_ISO8601;
  11. //get an unset variable
  12. $unset_var = 10;
  13. unset ($unset_var);
  14. // define some classes
  15. class classWithToString
  16. {
  17. public function __toString() {
  18. return "Class A object";
  19. }
  20. }
  21. class classWithoutToString
  22. {
  23. }
  24. // heredoc string
  25. $heredoc = <<<EOT
  26. hello world
  27. EOT;
  28. // add arrays
  29. $index_array = array (1, 2, 3);
  30. $assoc_array = array ('one' => 1, 'two' => 2);
  31. //array of values to iterate over
  32. $inputs = array(
  33. // int data
  34. 'int 0' => 0,
  35. 'int 1' => 1,
  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. );
  71. // loop through each element of the array for timestamp
  72. foreach($inputs as $key =>$value) {
  73. echo "\n--$key--\n";
  74. var_dump( gmdate($format, $value) );
  75. };
  76. ?>
  77. ===DONE===