fileobject_002.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. --TEST--
  2. SPL: SplFileObject::fgetc
  3. --FILE--
  4. <?php
  5. function test($name)
  6. {
  7. echo "===$name===\n";
  8. $o = new SplFileObject(dirname(__FILE__) . '/' . $name);
  9. var_dump($o->key());
  10. while(($c = $o->fgetc()) !== false)
  11. {
  12. var_dump($o->key(), $c, $o->eof());
  13. }
  14. echo "===EOF?===\n";
  15. var_dump($o->eof());
  16. var_dump($o->key());
  17. var_dump($o->eof());
  18. }
  19. test('fileobject_001a.txt');
  20. test('fileobject_001b.txt');
  21. ?>
  22. ===DONE===
  23. <?php exit(0); ?>
  24. --EXPECT--
  25. ===fileobject_001a.txt===
  26. int(0)
  27. int(0)
  28. string(1) "0"
  29. bool(false)
  30. int(1)
  31. string(1) "
  32. "
  33. bool(false)
  34. int(1)
  35. string(1) "1"
  36. bool(false)
  37. int(2)
  38. string(1) "
  39. "
  40. bool(false)
  41. int(2)
  42. string(1) "2"
  43. bool(false)
  44. int(3)
  45. string(1) "
  46. "
  47. bool(false)
  48. int(3)
  49. string(1) "3"
  50. bool(false)
  51. int(4)
  52. string(1) "
  53. "
  54. bool(false)
  55. int(4)
  56. string(1) "4"
  57. bool(false)
  58. int(5)
  59. string(1) "
  60. "
  61. bool(false)
  62. int(5)
  63. string(1) "5"
  64. bool(false)
  65. int(6)
  66. string(1) "
  67. "
  68. bool(false)
  69. ===EOF?===
  70. bool(true)
  71. int(6)
  72. bool(true)
  73. ===fileobject_001b.txt===
  74. int(0)
  75. int(0)
  76. string(1) "0"
  77. bool(false)
  78. int(1)
  79. string(1) "
  80. "
  81. bool(false)
  82. int(1)
  83. string(1) "1"
  84. bool(false)
  85. int(2)
  86. string(1) "
  87. "
  88. bool(false)
  89. int(2)
  90. string(1) "2"
  91. bool(false)
  92. int(3)
  93. string(1) "
  94. "
  95. bool(false)
  96. int(3)
  97. string(1) "3"
  98. bool(false)
  99. int(4)
  100. string(1) "
  101. "
  102. bool(false)
  103. int(4)
  104. string(1) "4"
  105. bool(false)
  106. int(5)
  107. string(1) "
  108. "
  109. bool(false)
  110. int(5)
  111. string(1) "5"
  112. bool(false)
  113. ===EOF?===
  114. bool(true)
  115. int(5)
  116. bool(true)
  117. ===DONE===