1--TEST-- 2Test fflush() function: usage variations - links as resource 3--SKIPIF-- 4<?php 5if( substr(PHP_OS, 0, 3) == 'WIN') 6 die("skip Links not valid on Windows"); 7?> 8--FILE-- 9<?php 10/* Prototype: bool fflush ( resource $handle ); 11 Description: Flushes the output to a file 12*/ 13 14/* test fflush() with handle to symbollic link */ 15 16$file_path = dirname(__FILE__); 17require $file_path.'/file.inc'; 18 19echo "*** Testing fflush(): with soft links to files opened in diff modes ***\n"; 20$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric"); 21$file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t", 22 "a", "ab", "at", "a+","a+b", "a+t"); 23 24$file_name = "$file_path/fflush_variation2.tmp"; 25$symlink_name = "$file_path/symlnk_fflush_variation2.tmp"; 26 27$count = 1; 28 29foreach( $file_types as $type ) { 30 echo "-- Iteration $count with file containing $type data --\n"; 31 foreach( $file_modes as $mode ) { 32 echo "-- link opened in $mode mode --\n"; 33 34 //creating the file 35 $file_handle = fopen($file_name, "w"); 36 if($file_handle == false) 37 exit("Error:failed to open file $file_name"); 38 39 //fill the file with some data if mode is append mode 40 if( substr($mode, 0, 1) == "a" ) 41 fill_file($file_handle, $type, 10); 42 43 //close the file 44 fclose($file_handle); 45 46 // creating the sym link 47 var_dump( symlink($file_name, $symlink_name) ); 48 $file_handle = fopen($symlink_name, $mode); 49 if($file_handle == false) 50 exit("Error:failed to open link $symlink_name"); 51 52 // filling data into the file 53 var_dump( fill_file($file_handle, $type, 50) ); 54 var_dump( fflush($file_handle) ); 55 fclose($file_handle); 56 57 // reading the data from the file 58 var_dump( readfile($symlink_name) ); 59 60 unlink($symlink_name); 61 unlink($file_name); 62 } 63 $count++; 64} 65 66echo "\n*** Done ***"; 67?> 68--EXPECTF-- 69*** Testing fflush(): with soft links to files opened in diff modes *** 70-- Iteration 1 with file containing empty data -- 71-- link opened in w mode -- 72bool(true) 73bool(true) 74bool(true) 75int(0) 76-- link opened in wb mode -- 77bool(true) 78bool(true) 79bool(true) 80int(0) 81-- link opened in wt mode -- 82bool(true) 83bool(true) 84bool(true) 85int(0) 86-- link opened in w+ mode -- 87bool(true) 88bool(true) 89bool(true) 90int(0) 91-- link opened in w+b mode -- 92bool(true) 93bool(true) 94bool(true) 95int(0) 96-- link opened in w+t mode -- 97bool(true) 98bool(true) 99bool(true) 100int(0) 101-- link opened in a mode -- 102bool(true) 103bool(true) 104bool(true) 105int(0) 106-- link opened in ab mode -- 107bool(true) 108bool(true) 109bool(true) 110int(0) 111-- link opened in at mode -- 112bool(true) 113bool(true) 114bool(true) 115int(0) 116-- link opened in a+ mode -- 117bool(true) 118bool(true) 119bool(true) 120int(0) 121-- link opened in a+b mode -- 122bool(true) 123bool(true) 124bool(true) 125int(0) 126-- link opened in a+t mode -- 127bool(true) 128bool(true) 129bool(true) 130int(0) 131-- Iteration 2 with file containing numeric data -- 132-- link opened in w mode -- 133bool(true) 134bool(true) 135bool(true) 13622222222222222222222222222222222222222222222222222int(50) 137-- link opened in wb mode -- 138bool(true) 139bool(true) 140bool(true) 14122222222222222222222222222222222222222222222222222int(50) 142-- link opened in wt mode -- 143bool(true) 144bool(true) 145bool(true) 14622222222222222222222222222222222222222222222222222int(50) 147-- link opened in w+ mode -- 148bool(true) 149bool(true) 150bool(true) 15122222222222222222222222222222222222222222222222222int(50) 152-- link opened in w+b mode -- 153bool(true) 154bool(true) 155bool(true) 15622222222222222222222222222222222222222222222222222int(50) 157-- link opened in w+t mode -- 158bool(true) 159bool(true) 160bool(true) 16122222222222222222222222222222222222222222222222222int(50) 162-- link opened in a mode -- 163bool(true) 164bool(true) 165bool(true) 166222222222222222222222222222222222222222222222222222222222222int(60) 167-- link opened in ab mode -- 168bool(true) 169bool(true) 170bool(true) 171222222222222222222222222222222222222222222222222222222222222int(60) 172-- link opened in at mode -- 173bool(true) 174bool(true) 175bool(true) 176222222222222222222222222222222222222222222222222222222222222int(60) 177-- link opened in a+ mode -- 178bool(true) 179bool(true) 180bool(true) 181222222222222222222222222222222222222222222222222222222222222int(60) 182-- link opened in a+b mode -- 183bool(true) 184bool(true) 185bool(true) 186222222222222222222222222222222222222222222222222222222222222int(60) 187-- link opened in a+t mode -- 188bool(true) 189bool(true) 190bool(true) 191222222222222222222222222222222222222222222222222222222222222int(60) 192-- Iteration 3 with file containing text data -- 193-- link opened in w mode -- 194bool(true) 195bool(true) 196bool(true) 197text text text text text text text text text text int(50) 198-- link opened in wb mode -- 199bool(true) 200bool(true) 201bool(true) 202text text text text text text text text text text int(50) 203-- link opened in wt mode -- 204bool(true) 205bool(true) 206bool(true) 207text text text text text text text text text text int(50) 208-- link opened in w+ mode -- 209bool(true) 210bool(true) 211bool(true) 212text text text text text text text text text text int(50) 213-- link opened in w+b mode -- 214bool(true) 215bool(true) 216bool(true) 217text text text text text text text text text text int(50) 218-- link opened in w+t mode -- 219bool(true) 220bool(true) 221bool(true) 222text text text text text text text text text text int(50) 223-- link opened in a mode -- 224bool(true) 225bool(true) 226bool(true) 227text text text text text text text text text text text text int(60) 228-- link opened in ab mode -- 229bool(true) 230bool(true) 231bool(true) 232text text text text text text text text text text text text int(60) 233-- link opened in at mode -- 234bool(true) 235bool(true) 236bool(true) 237text text text text text text text text text text text text int(60) 238-- link opened in a+ mode -- 239bool(true) 240bool(true) 241bool(true) 242text text text text text text text text text text text text int(60) 243-- link opened in a+b mode -- 244bool(true) 245bool(true) 246bool(true) 247text text text text text text text text text text text text int(60) 248-- link opened in a+t mode -- 249bool(true) 250bool(true) 251bool(true) 252text text text text text text text text text text text text int(60) 253-- Iteration 4 with file containing text_with_new_line data -- 254-- link opened in w mode -- 255bool(true) 256bool(true) 257bool(true) 258line 259line of text 260line 261line of text 262line 263line of tint(50) 264-- link opened in wb mode -- 265bool(true) 266bool(true) 267bool(true) 268line 269line of text 270line 271line of text 272line 273line of tint(50) 274-- link opened in wt mode -- 275bool(true) 276bool(true) 277bool(true) 278line 279line of text 280line 281line of text 282line 283line of tint(50) 284-- link opened in w+ mode -- 285bool(true) 286bool(true) 287bool(true) 288line 289line of text 290line 291line of text 292line 293line of tint(50) 294-- link opened in w+b mode -- 295bool(true) 296bool(true) 297bool(true) 298line 299line of text 300line 301line of text 302line 303line of tint(50) 304-- link opened in w+t mode -- 305bool(true) 306bool(true) 307bool(true) 308line 309line of text 310line 311line of text 312line 313line of tint(50) 314-- link opened in a mode -- 315bool(true) 316bool(true) 317bool(true) 318line 319line line 320line of text 321line 322line of text 323line 324line of tint(60) 325-- link opened in ab mode -- 326bool(true) 327bool(true) 328bool(true) 329line 330line line 331line of text 332line 333line of text 334line 335line of tint(60) 336-- link opened in at mode -- 337bool(true) 338bool(true) 339bool(true) 340line 341line line 342line of text 343line 344line of text 345line 346line of tint(60) 347-- link opened in a+ mode -- 348bool(true) 349bool(true) 350bool(true) 351line 352line line 353line of text 354line 355line of text 356line 357line of tint(60) 358-- link opened in a+b mode -- 359bool(true) 360bool(true) 361bool(true) 362line 363line line 364line of text 365line 366line of text 367line 368line of tint(60) 369-- link opened in a+t mode -- 370bool(true) 371bool(true) 372bool(true) 373line 374line line 375line of text 376line 377line of text 378line 379line of tint(60) 380-- Iteration 5 with file containing alphanumeric data -- 381-- link opened in w mode -- 382bool(true) 383bool(true) 384bool(true) 385ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) 386-- link opened in wb mode -- 387bool(true) 388bool(true) 389bool(true) 390ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) 391-- link opened in wt mode -- 392bool(true) 393bool(true) 394bool(true) 395ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) 396-- link opened in w+ mode -- 397bool(true) 398bool(true) 399bool(true) 400ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) 401-- link opened in w+b mode -- 402bool(true) 403bool(true) 404bool(true) 405ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) 406-- link opened in w+t mode -- 407bool(true) 408bool(true) 409bool(true) 410ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) 411-- link opened in a mode -- 412bool(true) 413bool(true) 414bool(true) 415ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) 416-- link opened in ab mode -- 417bool(true) 418bool(true) 419bool(true) 420ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) 421-- link opened in at mode -- 422bool(true) 423bool(true) 424bool(true) 425ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) 426-- link opened in a+ mode -- 427bool(true) 428bool(true) 429bool(true) 430ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) 431-- link opened in a+b mode -- 432bool(true) 433bool(true) 434bool(true) 435ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) 436-- link opened in a+t mode -- 437bool(true) 438bool(true) 439bool(true) 440ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) 441 442*** Done *** 443 444