1--TEST-- 2Test readfile() function: basic functionality 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip.. only on Linux'); 7} 8?> 9--FILE-- 10<?php 11// common file used 12require(__DIR__ . '/file.inc'); 13 14echo "*** Testing readfile() : basic functionality ***\n"; 15$file_path = __DIR__; 16$file_prefix = "readfile_basic"; // temp files created with this prefix 17 18// the content that is filled into the temp files as created 19$filetypes = array("numeric", "text", "empty", "alphanumeric", "text_with_new_line"); 20// different file modes 21$filemodes = array("w", "wt", "wb", "w+", "w+b", "w+t", 22 "a", "at", "ab", "a+", "a+b", "a+t", 23 "x", "xb", "xt", "x+", "x+b", "x+t"); 24 25// create file, read the file content, delete file 26foreach($filetypes as $type) { 27 echo "\n-- File filled with content type: $type --\n"; 28 foreach($filemodes as $mode) { 29 echo "-- File opened with mode: $mode --\n"; 30 if ( strstr($mode, "x") ) { 31 $fp = fopen($file_path."/".$file_prefix."1.tmp", $mode); 32 fill_file($fp, $type, 100); 33 fclose($fp); 34 } else { 35 // creating file in write mode 36 create_files($file_path, 1, $type, 0755, 100, $mode, $file_prefix, 1, "byte"); 37 } 38 $count = readfile($file_path."/".$file_prefix."1.tmp"); 39 echo "\n"; 40 var_dump($count); 41 // delete files created 42 delete_files($file_path, 1, $file_prefix, 1); 43 } 44} 45echo "Done\n"; 46?> 47--EXPECT-- 48*** Testing readfile() : basic functionality *** 49 50-- File filled with content type: numeric -- 51-- File opened with mode: w -- 522222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 53int(100) 54-- File opened with mode: wt -- 552222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 56int(100) 57-- File opened with mode: wb -- 582222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 59int(100) 60-- File opened with mode: w+ -- 612222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 62int(100) 63-- File opened with mode: w+b -- 642222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 65int(100) 66-- File opened with mode: w+t -- 672222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 68int(100) 69-- File opened with mode: a -- 702222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 71int(100) 72-- File opened with mode: at -- 732222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 74int(100) 75-- File opened with mode: ab -- 762222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 77int(100) 78-- File opened with mode: a+ -- 792222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 80int(100) 81-- File opened with mode: a+b -- 822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 83int(100) 84-- File opened with mode: a+t -- 852222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 86int(100) 87-- File opened with mode: x -- 882222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 89int(100) 90-- File opened with mode: xb -- 912222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 92int(100) 93-- File opened with mode: xt -- 942222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 95int(100) 96-- File opened with mode: x+ -- 972222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 98int(100) 99-- File opened with mode: x+b -- 1002222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 101int(100) 102-- File opened with mode: x+t -- 1032222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 104int(100) 105 106-- File filled with content type: text -- 107-- File opened with mode: w -- 108text text text text text text text text text text text text text text text text text text text text 109int(100) 110-- File opened with mode: wt -- 111text text text text text text text text text text text text text text text text text text text text 112int(100) 113-- File opened with mode: wb -- 114text text text text text text text text text text text text text text text text text text text text 115int(100) 116-- File opened with mode: w+ -- 117text text text text text text text text text text text text text text text text text text text text 118int(100) 119-- File opened with mode: w+b -- 120text text text text text text text text text text text text text text text text text text text text 121int(100) 122-- File opened with mode: w+t -- 123text text text text text text text text text text text text text text text text text text text text 124int(100) 125-- File opened with mode: a -- 126text text text text text text text text text text text text text text text text text text text text 127int(100) 128-- File opened with mode: at -- 129text text text text text text text text text text text text text text text text text text text text 130int(100) 131-- File opened with mode: ab -- 132text text text text text text text text text text text text text text text text text text text text 133int(100) 134-- File opened with mode: a+ -- 135text text text text text text text text text text text text text text text text text text text text 136int(100) 137-- File opened with mode: a+b -- 138text text text text text text text text text text text text text text text text text text text text 139int(100) 140-- File opened with mode: a+t -- 141text text text text text text text text text text text text text text text text text text text text 142int(100) 143-- File opened with mode: x -- 144text text text text text text text text text text text text text text text text text text text text 145int(100) 146-- File opened with mode: xb -- 147text text text text text text text text text text text text text text text text text text text text 148int(100) 149-- File opened with mode: xt -- 150text text text text text text text text text text text text text text text text text text text text 151int(100) 152-- File opened with mode: x+ -- 153text text text text text text text text text text text text text text text text text text text text 154int(100) 155-- File opened with mode: x+b -- 156text text text text text text text text text text text text text text text text text text text text 157int(100) 158-- File opened with mode: x+t -- 159text text text text text text text text text text text text text text text text text text text text 160int(100) 161 162-- File filled with content type: empty -- 163-- File opened with mode: w -- 164 165int(0) 166-- File opened with mode: wt -- 167 168int(0) 169-- File opened with mode: wb -- 170 171int(0) 172-- File opened with mode: w+ -- 173 174int(0) 175-- File opened with mode: w+b -- 176 177int(0) 178-- File opened with mode: w+t -- 179 180int(0) 181-- File opened with mode: a -- 182 183int(0) 184-- File opened with mode: at -- 185 186int(0) 187-- File opened with mode: ab -- 188 189int(0) 190-- File opened with mode: a+ -- 191 192int(0) 193-- File opened with mode: a+b -- 194 195int(0) 196-- File opened with mode: a+t -- 197 198int(0) 199-- File opened with mode: x -- 200 201int(0) 202-- File opened with mode: xb -- 203 204int(0) 205-- File opened with mode: xt -- 206 207int(0) 208-- File opened with mode: x+ -- 209 210int(0) 211-- File opened with mode: x+b -- 212 213int(0) 214-- File opened with mode: x+t -- 215 216int(0) 217 218-- File filled with content type: alphanumeric -- 219-- File opened with mode: w -- 220ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 221int(100) 222-- File opened with mode: wt -- 223ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 224int(100) 225-- File opened with mode: wb -- 226ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 227int(100) 228-- File opened with mode: w+ -- 229ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 230int(100) 231-- File opened with mode: w+b -- 232ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 233int(100) 234-- File opened with mode: w+t -- 235ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 236int(100) 237-- File opened with mode: a -- 238ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 239int(100) 240-- File opened with mode: at -- 241ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 242int(100) 243-- File opened with mode: ab -- 244ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 245int(100) 246-- File opened with mode: a+ -- 247ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 248int(100) 249-- File opened with mode: a+b -- 250ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 251int(100) 252-- File opened with mode: a+t -- 253ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 254int(100) 255-- File opened with mode: x -- 256ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 257int(100) 258-- File opened with mode: xb -- 259ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 260int(100) 261-- File opened with mode: xt -- 262ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 263int(100) 264-- File opened with mode: x+ -- 265ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 266int(100) 267-- File opened with mode: x+b -- 268ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 269int(100) 270-- File opened with mode: x+t -- 271ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 272int(100) 273 274-- File filled with content type: text_with_new_line -- 275-- File opened with mode: w -- 276line 277line of text 278line 279line of text 280line 281line of text 282line 283line of text 284line 285line of text 286line 287line 288int(100) 289-- File opened with mode: wt -- 290line 291line of text 292line 293line of text 294line 295line of text 296line 297line of text 298line 299line of text 300line 301line 302int(100) 303-- File opened with mode: wb -- 304line 305line of text 306line 307line of text 308line 309line of text 310line 311line of text 312line 313line of text 314line 315line 316int(100) 317-- File opened with mode: w+ -- 318line 319line of text 320line 321line of text 322line 323line of text 324line 325line of text 326line 327line of text 328line 329line 330int(100) 331-- File opened with mode: w+b -- 332line 333line of text 334line 335line of text 336line 337line of text 338line 339line of text 340line 341line of text 342line 343line 344int(100) 345-- File opened with mode: w+t -- 346line 347line of text 348line 349line of text 350line 351line of text 352line 353line of text 354line 355line of text 356line 357line 358int(100) 359-- File opened with mode: a -- 360line 361line of text 362line 363line of text 364line 365line of text 366line 367line of text 368line 369line of text 370line 371line 372int(100) 373-- File opened with mode: at -- 374line 375line of text 376line 377line of text 378line 379line of text 380line 381line of text 382line 383line of text 384line 385line 386int(100) 387-- File opened with mode: ab -- 388line 389line of text 390line 391line of text 392line 393line of text 394line 395line of text 396line 397line of text 398line 399line 400int(100) 401-- File opened with mode: a+ -- 402line 403line of text 404line 405line of text 406line 407line of text 408line 409line of text 410line 411line of text 412line 413line 414int(100) 415-- File opened with mode: a+b -- 416line 417line of text 418line 419line of text 420line 421line of text 422line 423line of text 424line 425line of text 426line 427line 428int(100) 429-- File opened with mode: a+t -- 430line 431line of text 432line 433line of text 434line 435line of text 436line 437line of text 438line 439line of text 440line 441line 442int(100) 443-- File opened with mode: x -- 444line 445line of text 446line 447line of text 448line 449line of text 450line 451line of text 452line 453line of text 454line 455line 456int(100) 457-- File opened with mode: xb -- 458line 459line of text 460line 461line of text 462line 463line of text 464line 465line of text 466line 467line of text 468line 469line 470int(100) 471-- File opened with mode: xt -- 472line 473line of text 474line 475line of text 476line 477line of text 478line 479line of text 480line 481line of text 482line 483line 484int(100) 485-- File opened with mode: x+ -- 486line 487line of text 488line 489line of text 490line 491line of text 492line 493line of text 494line 495line of text 496line 497line 498int(100) 499-- File opened with mode: x+b -- 500line 501line of text 502line 503line of text 504line 505line of text 506line 507line of text 508line 509line of text 510line 511line 512int(100) 513-- File opened with mode: x+t -- 514line 515line of text 516line 517line of text 518line 519line of text 520line 521line of text 522line 523line of text 524line 525line 526int(100) 527Done 528