PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

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