PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 101 lines | 57 code | 21 blank | 23 comment | 2 complexity | 145a1f7143daa81582ba5b1908912b01 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 dirname(string path)
  3. * Description: Returns the directory name component of the path
  4. * Source code: ext/standard/string.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing dirname() : 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. //get an unset variable
  18. $unset_var = 10;
  19. unset ($unset_var);
  20. // define some classes
  21. class classWithToString
  22. {
  23. public function __toString() {
  24. return "Class A object";
  25. }
  26. }
  27. class classWithoutToString
  28. {
  29. }
  30. // heredoc string
  31. $heredoc = <<<EOT
  32. hello world
  33. EOT;
  34. // add arrays
  35. $index_array = array (1, 2, 3);
  36. $assoc_array = array ('one' => 1, 'two' => 2);
  37. //array of values to iterate over
  38. $inputs = array(
  39. // int data
  40. 'int 0' => 0,
  41. 'int 1' => 1,
  42. 'int 12345' => 12345,
  43. 'int -12345' => -2345,
  44. // float data
  45. 'float 10.5' => 10.5,
  46. 'float -10.5' => -10.5,
  47. 'float 12.3456789000e10' => 12.3456789000e10,
  48. 'float -12.3456789000e10' => -12.3456789000e10,
  49. 'float .5' => .5,
  50. // array data
  51. 'empty array' => array(),
  52. 'int indexed array' => $index_array,
  53. 'associative array' => $assoc_array,
  54. 'nested arrays' => array('foo', $index_array, $assoc_array),
  55. // null data
  56. 'uppercase NULL' => NULL,
  57. 'lowercase null' => null,
  58. // boolean data
  59. 'lowercase true' => true,
  60. 'lowercase false' =>false,
  61. 'uppercase TRUE' =>TRUE,
  62. 'uppercase FALSE' =>FALSE,
  63. // empty data
  64. 'empty string DQ' => "",
  65. 'empty string SQ' => '',
  66. // object data
  67. 'instance of classWithToString' => new classWithToString(),
  68. 'instance of classWithoutToString' => new classWithoutToString(),
  69. // undefined data
  70. 'undefined var' => @$undefined_var,
  71. // unset data
  72. 'unset var' => @$unset_var,
  73. );
  74. // loop through each element of the array for path
  75. foreach($inputs as $key =>$value) {
  76. echo "\n--$key--\n";
  77. var_dump( dirname($value) );
  78. };
  79. ?>
  80. ===DONE===