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

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

http://github.com/facebook/hiphop-php
PHP | 102 lines | 58 code | 21 blank | 23 comment | 2 complexity | 28ef5f8cf8ed83822a0ce549ff7c12e6 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 : array pathinfo(string path[, int options])
  3. * Description: Returns information about a certain string
  4. * Source code: ext/standard/string.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing pathinfo() : 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. $options = PATHINFO_DIRNAME;
  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. // int data
  41. 'int 0' => 0,
  42. 'int 1' => 1,
  43. 'int 12345' => 12345,
  44. 'int -12345' => -2345,
  45. // float data
  46. 'float 10.5' => 10.5,
  47. 'float -10.5' => -10.5,
  48. 'float 12.3456789000e10' => 12.3456789000e10,
  49. 'float -12.3456789000e10' => -12.3456789000e10,
  50. 'float .5' => .5,
  51. // array data
  52. 'empty array' => array(),
  53. 'int indexed array' => $index_array,
  54. 'associative array' => $assoc_array,
  55. 'nested arrays' => array('foo', $index_array, $assoc_array),
  56. // null data
  57. 'uppercase NULL' => NULL,
  58. 'lowercase null' => null,
  59. // boolean data
  60. 'lowercase true' => true,
  61. 'lowercase false' =>false,
  62. 'uppercase TRUE' =>TRUE,
  63. 'uppercase FALSE' =>FALSE,
  64. // empty data
  65. 'empty string DQ' => "",
  66. 'empty string SQ' => '',
  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 path
  76. foreach($inputs as $key =>$value) {
  77. echo "\n--$key--\n";
  78. var_dump( pathinfo($value, $options) );
  79. };
  80. ?>
  81. ===DONE===