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

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

http://github.com/facebook/hiphop-php
PHP | 105 lines | 58 code | 24 blank | 23 comment | 0 complexity | 8baae6057e56a8a845e86c818796cf74 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 date ( string $format [, int $timestamp ] )
  3. * Description: Format a local time/date.
  4. * Source code: ext/date/php_date.c
  5. */
  6. echo "*** Testing date() : usage variation - unexpected values to second argument \$timestamp***\n";
  7. //Set the default time zone
  8. date_default_timezone_set("Europe/London");
  9. //get an unset variable
  10. $unset_var = 10;
  11. unset ($unset_var);
  12. // define some classes
  13. class classWithToString
  14. {
  15. public function __toString() {
  16. return "Class A object";
  17. }
  18. }
  19. class classWithoutToString
  20. {
  21. }
  22. // heredoc string
  23. $heredoc = <<<EOT
  24. hello world
  25. EOT;
  26. // add arrays
  27. $index_array = array (1, 2, 3);
  28. $assoc_array = array ('one' => 1, 'two' => 2);
  29. // resource
  30. $file_handle = fopen(__FILE__, 'r');
  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. // resource
  71. 'resource' => $file_handle
  72. );
  73. $format = "F j, Y, g:i a";
  74. foreach($inputs as $variation =>$timestamp) {
  75. echo "\n-- $variation --\n";
  76. var_dump( date($format, $timestamp) );
  77. };
  78. // closing the resource
  79. fclose( $file_handle );
  80. ?>
  81. ===DONE===