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

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

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