PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/standard/tests/file/mkdir_variation2.php

http://github.com/facebook/hiphop-php
PHP | 106 lines | 62 code | 21 blank | 23 comment | 3 complexity | 3c87bac7c015ab995ba29e8c3f280cfa 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 : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
  3. * Description: Create a directory
  4. * Source code: ext/standard/file.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing mkdir() : usage variation ***\n";
  8. // Define error handler
  9. function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
  10. if (error_reporting() != 0) {
  11. // report non-silenced errors
  12. echo "Error: $err_no - $err_msg, $filename($linenum)\n";
  13. }
  14. }
  15. set_error_handler('test_error_handler');
  16. // Initialise function arguments not being substituted (if any)
  17. $pathname = 'mkdirVar2.tmp';
  18. //get an unset variable
  19. $unset_var = 10;
  20. unset ($unset_var);
  21. // define some classes
  22. class classWithToString
  23. {
  24. public function __toString() {
  25. return "Class A object";
  26. }
  27. }
  28. class classWithoutToString
  29. {
  30. }
  31. // heredoc string
  32. $heredoc = <<<EOT
  33. hello world
  34. EOT;
  35. // add arrays
  36. $index_array = array (1, 2, 3);
  37. $assoc_array = array ('one' => 1, 'two' => 2);
  38. //array of values to iterate over
  39. $inputs = array(
  40. // float data
  41. 'float 10.5' => 10.5,
  42. 'float -10.5' => -10.5,
  43. 'float 12.3456789000e10' => 12.3456789000e10,
  44. 'float -12.3456789000e10' => -12.3456789000e10,
  45. 'float .5' => .5,
  46. // array data
  47. 'empty array' => array(),
  48. 'int indexed array' => $index_array,
  49. 'associative array' => $assoc_array,
  50. 'nested arrays' => array('foo', $index_array, $assoc_array),
  51. // null data
  52. 'uppercase NULL' => NULL,
  53. 'lowercase null' => null,
  54. // boolean data
  55. 'lowercase true' => true,
  56. 'lowercase false' =>false,
  57. 'uppercase TRUE' =>TRUE,
  58. 'uppercase FALSE' =>FALSE,
  59. // empty data
  60. 'empty string DQ' => "",
  61. 'empty string SQ' => '',
  62. // string data
  63. 'string DQ' => "string",
  64. 'string SQ' => 'string',
  65. 'mixed case string' => "sTrInG",
  66. 'heredoc' => $heredoc,
  67. // object data
  68. 'instance of classWithToString' => new classWithToString(),
  69. 'instance of classWithoutToString' => new classWithoutToString(),
  70. // undefined data
  71. 'undefined var' => @$undefined_var,
  72. // unset data
  73. 'unset var' => @$unset_var,
  74. );
  75. // loop through each element of the array for mode
  76. foreach($inputs as $key =>$value) {
  77. echo "\n--$key--\n";
  78. $h = mkdir($pathname, $value);
  79. if ($h === true) {
  80. echo "Directory created\n";
  81. rmdir($pathname);
  82. }
  83. };
  84. ?>
  85. ===DONE===