PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 94 lines | 53 code | 20 blank | 21 comment | 0 complexity | 76a768fe3cb1be8b6ac2bcd5a1e37960 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 gmstrftime(string format [, int timestamp])
  3. * Description: Format a GMT/UCT time/date according to locale settings
  4. * Source code: ext/date/php_date.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing gmstrftime() : usage variation ***\n";
  8. // Initialise function arguments not being substituted (if any)
  9. $timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
  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. //array of values to iterate over
  31. $inputs = array(
  32. // int data
  33. 'int 0' => 0,
  34. 'int 1' => 1,
  35. 'int 12345' => 12345,
  36. 'int -12345' => -12345,
  37. // float data
  38. 'float 10.5' => 10.5,
  39. 'float -10.5' => -10.5,
  40. 'float 12.3456789000e10' => 12.3456789000e10,
  41. 'float -12.3456789000e10' => -12.3456789000e10,
  42. 'float .5' => .5,
  43. // array data
  44. 'empty array' => array(),
  45. 'int indexed array' => $index_array,
  46. 'associative array' => $assoc_array,
  47. 'nested arrays' => array('foo', $index_array, $assoc_array),
  48. // null data
  49. 'uppercase NULL' => NULL,
  50. 'lowercase null' => null,
  51. // boolean data
  52. 'lowercase true' => true,
  53. 'lowercase false' =>false,
  54. 'uppercase TRUE' =>TRUE,
  55. 'uppercase FALSE' =>FALSE,
  56. // empty data
  57. 'empty string DQ' => "",
  58. 'empty string SQ' => '',
  59. // object data
  60. 'instance of classWithToString' => new classWithToString(),
  61. 'instance of classWithoutToString' => new classWithoutToString(),
  62. // undefined data
  63. 'undefined var' => @$undefined_var,
  64. // unset data
  65. 'unset var' => @$unset_var,
  66. );
  67. // loop through each element of the array for format
  68. foreach($inputs as $key =>$value) {
  69. echo "\n--$key--\n";
  70. var_dump( gmstrftime($value) );
  71. var_dump( gmstrftime($value, $timestamp) );
  72. };
  73. ?>
  74. ===DONE===