Annotation of embedaddon/php/ext/standard/tests/file/fputcsv_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test fputcsv() : usage variations - with all parameters specified
! 3: --FILE--
! 4: <?php
! 5: /*
! 6: Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
! 7: Description: Format line as CSV and write to the file pointer
! 8: */
! 9:
! 10: /* Testing fputcsv() to write to a file when all its parameters are provided */
! 11:
! 12: echo "*** Testing fputcsv() : with all parameters specified ***\n";
! 13:
! 14: /* the array is with three elements in it. Each element should be read as
! 15: 1st element is delimiter, 2nd element is enclosure
! 16: and 3rd element is csv fields
! 17: */
! 18: $csv_lists = array (
! 19: array(',', '"', array('water','fruit') ),
! 20: array(',', '"', array('"water","fruit') ),
! 21: array(',', '"', array('"water","fruit"') ),
! 22: array(' ', '^', array('^water^ ^fruit^')),
! 23: array(':', '&', array('&water&:&fruit&')),
! 24: array('=', '=', array('=water===fruit=')),
! 25: array('-', '-', array('-water--fruit-air')),
! 26: array('-', '-', array('-water---fruit---air-')),
! 27: array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
! 28:
! 29: );
! 30: $file_path = dirname(__FILE__);
! 31: $filename = "$file_path/fputcsv_variation1.tmp";
! 32:
! 33: $file_modes = array ("r+", "r+b", "r+t",
! 34: "a+", "a+b", "a+t",
! 35: "w+", "w+b", "w+t",
! 36: "x+", "x+b", "x+t");
! 37:
! 38: $loop_counter = 1;
! 39: foreach ($csv_lists as $csv_list) {
! 40: for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
! 41:
! 42: echo "\n-- file opened in $file_modes[$mode_counter] --\n";
! 43: // create the file and add the content with has csv fields
! 44: if ( strstr($file_modes[$mode_counter], "r") ) {
! 45: $file_handle = fopen($filename, "w");
! 46: } else {
! 47: $file_handle = fopen($filename, $file_modes[$mode_counter] );
! 48: }
! 49: if ( !$file_handle ) {
! 50: echo "Error: failed to create file $filename!\n";
! 51: exit();
! 52: }
! 53: $delimiter = $csv_list[0];
! 54: $enclosure = $csv_list[1];
! 55: $csv_field = $csv_list[2];
! 56:
! 57:
! 58: var_dump( fputcsv($file_handle, $csv_field, $delimiter, $enclosure) );
! 59: // check the file pointer position and eof
! 60: var_dump( ftell($file_handle) );
! 61: var_dump( feof($file_handle) );
! 62: //close the file
! 63: fclose($file_handle);
! 64:
! 65: // print the file contents
! 66: var_dump( file_get_contents($filename) );
! 67:
! 68: //delete file
! 69: unlink($filename);
! 70: } //end of mode loop
! 71: } // end of foreach
! 72:
! 73: echo "Done\n";
! 74: ?>
! 75: --EXPECTF--
! 76: *** Testing fputcsv() : with all parameters specified ***
! 77:
! 78: -- file opened in r+ --
! 79: int(12)
! 80: int(12)
! 81: bool(false)
! 82: string(12) "water,fruit
! 83: "
! 84:
! 85: -- file opened in r+b --
! 86: int(12)
! 87: int(12)
! 88: bool(false)
! 89: string(12) "water,fruit
! 90: "
! 91:
! 92: -- file opened in r+t --
! 93: int(12)
! 94: int(12)
! 95: bool(false)
! 96: string(%d) "water,fruit
! 97: "
! 98:
! 99: -- file opened in a+ --
! 100: int(12)
! 101: int(12)
! 102: bool(false)
! 103: string(12) "water,fruit
! 104: "
! 105:
! 106: -- file opened in a+b --
! 107: int(12)
! 108: int(12)
! 109: bool(false)
! 110: string(12) "water,fruit
! 111: "
! 112:
! 113: -- file opened in a+t --
! 114: int(12)
! 115: int(12)
! 116: bool(false)
! 117: string(%d) "water,fruit
! 118: "
! 119:
! 120: -- file opened in w+ --
! 121: int(12)
! 122: int(12)
! 123: bool(false)
! 124: string(12) "water,fruit
! 125: "
! 126:
! 127: -- file opened in w+b --
! 128: int(12)
! 129: int(12)
! 130: bool(false)
! 131: string(12) "water,fruit
! 132: "
! 133:
! 134: -- file opened in w+t --
! 135: int(12)
! 136: int(12)
! 137: bool(false)
! 138: string(%d) "water,fruit
! 139: "
! 140:
! 141: -- file opened in x+ --
! 142: int(12)
! 143: int(12)
! 144: bool(false)
! 145: string(12) "water,fruit
! 146: "
! 147:
! 148: -- file opened in x+b --
! 149: int(12)
! 150: int(12)
! 151: bool(false)
! 152: string(12) "water,fruit
! 153: "
! 154:
! 155: -- file opened in x+t --
! 156: int(12)
! 157: int(12)
! 158: bool(false)
! 159: string(%d) "water,fruit
! 160: "
! 161:
! 162: -- file opened in r+ --
! 163: int(20)
! 164: int(20)
! 165: bool(false)
! 166: string(20) """"water"",""fruit"
! 167: "
! 168:
! 169: -- file opened in r+b --
! 170: int(20)
! 171: int(20)
! 172: bool(false)
! 173: string(20) """"water"",""fruit"
! 174: "
! 175:
! 176: -- file opened in r+t --
! 177: int(20)
! 178: int(20)
! 179: bool(false)
! 180: string(%d) """"water"",""fruit"
! 181: "
! 182:
! 183: -- file opened in a+ --
! 184: int(20)
! 185: int(20)
! 186: bool(false)
! 187: string(20) """"water"",""fruit"
! 188: "
! 189:
! 190: -- file opened in a+b --
! 191: int(20)
! 192: int(20)
! 193: bool(false)
! 194: string(20) """"water"",""fruit"
! 195: "
! 196:
! 197: -- file opened in a+t --
! 198: int(20)
! 199: int(20)
! 200: bool(false)
! 201: string(%d) """"water"",""fruit"
! 202: "
! 203:
! 204: -- file opened in w+ --
! 205: int(20)
! 206: int(20)
! 207: bool(false)
! 208: string(20) """"water"",""fruit"
! 209: "
! 210:
! 211: -- file opened in w+b --
! 212: int(20)
! 213: int(20)
! 214: bool(false)
! 215: string(20) """"water"",""fruit"
! 216: "
! 217:
! 218: -- file opened in w+t --
! 219: int(20)
! 220: int(20)
! 221: bool(false)
! 222: string(%d) """"water"",""fruit"
! 223: "
! 224:
! 225: -- file opened in x+ --
! 226: int(20)
! 227: int(20)
! 228: bool(false)
! 229: string(20) """"water"",""fruit"
! 230: "
! 231:
! 232: -- file opened in x+b --
! 233: int(20)
! 234: int(20)
! 235: bool(false)
! 236: string(20) """"water"",""fruit"
! 237: "
! 238:
! 239: -- file opened in x+t --
! 240: int(20)
! 241: int(20)
! 242: bool(false)
! 243: string(%d) """"water"",""fruit"
! 244: "
! 245:
! 246: -- file opened in r+ --
! 247: int(22)
! 248: int(22)
! 249: bool(false)
! 250: string(22) """"water"",""fruit"""
! 251: "
! 252:
! 253: -- file opened in r+b --
! 254: int(22)
! 255: int(22)
! 256: bool(false)
! 257: string(22) """"water"",""fruit"""
! 258: "
! 259:
! 260: -- file opened in r+t --
! 261: int(22)
! 262: int(22)
! 263: bool(false)
! 264: string(%d) """"water"",""fruit"""
! 265: "
! 266:
! 267: -- file opened in a+ --
! 268: int(22)
! 269: int(22)
! 270: bool(false)
! 271: string(22) """"water"",""fruit"""
! 272: "
! 273:
! 274: -- file opened in a+b --
! 275: int(22)
! 276: int(22)
! 277: bool(false)
! 278: string(22) """"water"",""fruit"""
! 279: "
! 280:
! 281: -- file opened in a+t --
! 282: int(22)
! 283: int(22)
! 284: bool(false)
! 285: string(%d) """"water"",""fruit"""
! 286: "
! 287:
! 288: -- file opened in w+ --
! 289: int(22)
! 290: int(22)
! 291: bool(false)
! 292: string(22) """"water"",""fruit"""
! 293: "
! 294:
! 295: -- file opened in w+b --
! 296: int(22)
! 297: int(22)
! 298: bool(false)
! 299: string(22) """"water"",""fruit"""
! 300: "
! 301:
! 302: -- file opened in w+t --
! 303: int(22)
! 304: int(22)
! 305: bool(false)
! 306: string(%d) """"water"",""fruit"""
! 307: "
! 308:
! 309: -- file opened in x+ --
! 310: int(22)
! 311: int(22)
! 312: bool(false)
! 313: string(22) """"water"",""fruit"""
! 314: "
! 315:
! 316: -- file opened in x+b --
! 317: int(22)
! 318: int(22)
! 319: bool(false)
! 320: string(22) """"water"",""fruit"""
! 321: "
! 322:
! 323: -- file opened in x+t --
! 324: int(22)
! 325: int(22)
! 326: bool(false)
! 327: string(%d) """"water"",""fruit"""
! 328: "
! 329:
! 330: -- file opened in r+ --
! 331: int(22)
! 332: int(22)
! 333: bool(false)
! 334: string(22) "^^^water^^ ^^fruit^^^
! 335: "
! 336:
! 337: -- file opened in r+b --
! 338: int(22)
! 339: int(22)
! 340: bool(false)
! 341: string(22) "^^^water^^ ^^fruit^^^
! 342: "
! 343:
! 344: -- file opened in r+t --
! 345: int(22)
! 346: int(22)
! 347: bool(false)
! 348: string(%d) "^^^water^^ ^^fruit^^^
! 349: "
! 350:
! 351: -- file opened in a+ --
! 352: int(22)
! 353: int(22)
! 354: bool(false)
! 355: string(22) "^^^water^^ ^^fruit^^^
! 356: "
! 357:
! 358: -- file opened in a+b --
! 359: int(22)
! 360: int(22)
! 361: bool(false)
! 362: string(22) "^^^water^^ ^^fruit^^^
! 363: "
! 364:
! 365: -- file opened in a+t --
! 366: int(22)
! 367: int(22)
! 368: bool(false)
! 369: string(%d) "^^^water^^ ^^fruit^^^
! 370: "
! 371:
! 372: -- file opened in w+ --
! 373: int(22)
! 374: int(22)
! 375: bool(false)
! 376: string(22) "^^^water^^ ^^fruit^^^
! 377: "
! 378:
! 379: -- file opened in w+b --
! 380: int(22)
! 381: int(22)
! 382: bool(false)
! 383: string(22) "^^^water^^ ^^fruit^^^
! 384: "
! 385:
! 386: -- file opened in w+t --
! 387: int(22)
! 388: int(22)
! 389: bool(false)
! 390: string(%d) "^^^water^^ ^^fruit^^^
! 391: "
! 392:
! 393: -- file opened in x+ --
! 394: int(22)
! 395: int(22)
! 396: bool(false)
! 397: string(22) "^^^water^^ ^^fruit^^^
! 398: "
! 399:
! 400: -- file opened in x+b --
! 401: int(22)
! 402: int(22)
! 403: bool(false)
! 404: string(22) "^^^water^^ ^^fruit^^^
! 405: "
! 406:
! 407: -- file opened in x+t --
! 408: int(22)
! 409: int(22)
! 410: bool(false)
! 411: string(%d) "^^^water^^ ^^fruit^^^
! 412: "
! 413:
! 414: -- file opened in r+ --
! 415: int(22)
! 416: int(22)
! 417: bool(false)
! 418: string(22) "&&&water&&:&&fruit&&&
! 419: "
! 420:
! 421: -- file opened in r+b --
! 422: int(22)
! 423: int(22)
! 424: bool(false)
! 425: string(22) "&&&water&&:&&fruit&&&
! 426: "
! 427:
! 428: -- file opened in r+t --
! 429: int(22)
! 430: int(22)
! 431: bool(false)
! 432: string(%d) "&&&water&&:&&fruit&&&
! 433: "
! 434:
! 435: -- file opened in a+ --
! 436: int(22)
! 437: int(22)
! 438: bool(false)
! 439: string(22) "&&&water&&:&&fruit&&&
! 440: "
! 441:
! 442: -- file opened in a+b --
! 443: int(22)
! 444: int(22)
! 445: bool(false)
! 446: string(22) "&&&water&&:&&fruit&&&
! 447: "
! 448:
! 449: -- file opened in a+t --
! 450: int(22)
! 451: int(22)
! 452: bool(false)
! 453: string(%d) "&&&water&&:&&fruit&&&
! 454: "
! 455:
! 456: -- file opened in w+ --
! 457: int(22)
! 458: int(22)
! 459: bool(false)
! 460: string(22) "&&&water&&:&&fruit&&&
! 461: "
! 462:
! 463: -- file opened in w+b --
! 464: int(22)
! 465: int(22)
! 466: bool(false)
! 467: string(22) "&&&water&&:&&fruit&&&
! 468: "
! 469:
! 470: -- file opened in w+t --
! 471: int(22)
! 472: int(22)
! 473: bool(false)
! 474: string(%d) "&&&water&&:&&fruit&&&
! 475: "
! 476:
! 477: -- file opened in x+ --
! 478: int(22)
! 479: int(22)
! 480: bool(false)
! 481: string(22) "&&&water&&:&&fruit&&&
! 482: "
! 483:
! 484: -- file opened in x+b --
! 485: int(22)
! 486: int(22)
! 487: bool(false)
! 488: string(22) "&&&water&&:&&fruit&&&
! 489: "
! 490:
! 491: -- file opened in x+t --
! 492: int(22)
! 493: int(22)
! 494: bool(false)
! 495: string(%d) "&&&water&&:&&fruit&&&
! 496: "
! 497:
! 498: -- file opened in r+ --
! 499: int(23)
! 500: int(23)
! 501: bool(false)
! 502: string(23) "===water======fruit===
! 503: "
! 504:
! 505: -- file opened in r+b --
! 506: int(23)
! 507: int(23)
! 508: bool(false)
! 509: string(23) "===water======fruit===
! 510: "
! 511:
! 512: -- file opened in r+t --
! 513: int(23)
! 514: int(23)
! 515: bool(false)
! 516: string(%d) "===water======fruit===
! 517: "
! 518:
! 519: -- file opened in a+ --
! 520: int(23)
! 521: int(23)
! 522: bool(false)
! 523: string(23) "===water======fruit===
! 524: "
! 525:
! 526: -- file opened in a+b --
! 527: int(23)
! 528: int(23)
! 529: bool(false)
! 530: string(23) "===water======fruit===
! 531: "
! 532:
! 533: -- file opened in a+t --
! 534: int(23)
! 535: int(23)
! 536: bool(false)
! 537: string(%d) "===water======fruit===
! 538: "
! 539:
! 540: -- file opened in w+ --
! 541: int(23)
! 542: int(23)
! 543: bool(false)
! 544: string(23) "===water======fruit===
! 545: "
! 546:
! 547: -- file opened in w+b --
! 548: int(23)
! 549: int(23)
! 550: bool(false)
! 551: string(23) "===water======fruit===
! 552: "
! 553:
! 554: -- file opened in w+t --
! 555: int(23)
! 556: int(23)
! 557: bool(false)
! 558: string(%d) "===water======fruit===
! 559: "
! 560:
! 561: -- file opened in x+ --
! 562: int(23)
! 563: int(23)
! 564: bool(false)
! 565: string(23) "===water======fruit===
! 566: "
! 567:
! 568: -- file opened in x+b --
! 569: int(23)
! 570: int(23)
! 571: bool(false)
! 572: string(23) "===water======fruit===
! 573: "
! 574:
! 575: -- file opened in x+t --
! 576: int(23)
! 577: int(23)
! 578: bool(false)
! 579: string(%d) "===water======fruit===
! 580: "
! 581:
! 582: -- file opened in r+ --
! 583: int(24)
! 584: int(24)
! 585: bool(false)
! 586: string(24) "---water----fruit--air-
! 587: "
! 588:
! 589: -- file opened in r+b --
! 590: int(24)
! 591: int(24)
! 592: bool(false)
! 593: string(24) "---water----fruit--air-
! 594: "
! 595:
! 596: -- file opened in r+t --
! 597: int(24)
! 598: int(24)
! 599: bool(false)
! 600: string(%d) "---water----fruit--air-
! 601: "
! 602:
! 603: -- file opened in a+ --
! 604: int(24)
! 605: int(24)
! 606: bool(false)
! 607: string(24) "---water----fruit--air-
! 608: "
! 609:
! 610: -- file opened in a+b --
! 611: int(24)
! 612: int(24)
! 613: bool(false)
! 614: string(24) "---water----fruit--air-
! 615: "
! 616:
! 617: -- file opened in a+t --
! 618: int(24)
! 619: int(24)
! 620: bool(false)
! 621: string(%d) "---water----fruit--air-
! 622: "
! 623:
! 624: -- file opened in w+ --
! 625: int(24)
! 626: int(24)
! 627: bool(false)
! 628: string(24) "---water----fruit--air-
! 629: "
! 630:
! 631: -- file opened in w+b --
! 632: int(24)
! 633: int(24)
! 634: bool(false)
! 635: string(24) "---water----fruit--air-
! 636: "
! 637:
! 638: -- file opened in w+t --
! 639: int(24)
! 640: int(24)
! 641: bool(false)
! 642: string(%d) "---water----fruit--air-
! 643: "
! 644:
! 645: -- file opened in x+ --
! 646: int(24)
! 647: int(24)
! 648: bool(false)
! 649: string(24) "---water----fruit--air-
! 650: "
! 651:
! 652: -- file opened in x+b --
! 653: int(24)
! 654: int(24)
! 655: bool(false)
! 656: string(24) "---water----fruit--air-
! 657: "
! 658:
! 659: -- file opened in x+t --
! 660: int(24)
! 661: int(24)
! 662: bool(false)
! 663: string(%d) "---water----fruit--air-
! 664: "
! 665:
! 666: -- file opened in r+ --
! 667: int(32)
! 668: int(32)
! 669: bool(false)
! 670: string(32) "---water------fruit------air---
! 671: "
! 672:
! 673: -- file opened in r+b --
! 674: int(32)
! 675: int(32)
! 676: bool(false)
! 677: string(32) "---water------fruit------air---
! 678: "
! 679:
! 680: -- file opened in r+t --
! 681: int(32)
! 682: int(32)
! 683: bool(false)
! 684: string(%d) "---water------fruit------air---
! 685: "
! 686:
! 687: -- file opened in a+ --
! 688: int(32)
! 689: int(32)
! 690: bool(false)
! 691: string(32) "---water------fruit------air---
! 692: "
! 693:
! 694: -- file opened in a+b --
! 695: int(32)
! 696: int(32)
! 697: bool(false)
! 698: string(32) "---water------fruit------air---
! 699: "
! 700:
! 701: -- file opened in a+t --
! 702: int(32)
! 703: int(32)
! 704: bool(false)
! 705: string(%d) "---water------fruit------air---
! 706: "
! 707:
! 708: -- file opened in w+ --
! 709: int(32)
! 710: int(32)
! 711: bool(false)
! 712: string(32) "---water------fruit------air---
! 713: "
! 714:
! 715: -- file opened in w+b --
! 716: int(32)
! 717: int(32)
! 718: bool(false)
! 719: string(32) "---water------fruit------air---
! 720: "
! 721:
! 722: -- file opened in w+t --
! 723: int(32)
! 724: int(32)
! 725: bool(false)
! 726: string(%d) "---water------fruit------air---
! 727: "
! 728:
! 729: -- file opened in x+ --
! 730: int(32)
! 731: int(32)
! 732: bool(false)
! 733: string(32) "---water------fruit------air---
! 734: "
! 735:
! 736: -- file opened in x+b --
! 737: int(32)
! 738: int(32)
! 739: bool(false)
! 740: string(32) "---water------fruit------air---
! 741: "
! 742:
! 743: -- file opened in x+t --
! 744: int(32)
! 745: int(32)
! 746: bool(false)
! 747: string(%d) "---water------fruit------air---
! 748: "
! 749:
! 750: -- file opened in r+ --
! 751: int(32)
! 752: int(32)
! 753: bool(false)
! 754: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 755: "
! 756:
! 757: -- file opened in r+b --
! 758: int(32)
! 759: int(32)
! 760: bool(false)
! 761: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 762: "
! 763:
! 764: -- file opened in r+t --
! 765: int(32)
! 766: int(32)
! 767: bool(false)
! 768: string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 769: "
! 770:
! 771: -- file opened in a+ --
! 772: int(32)
! 773: int(32)
! 774: bool(false)
! 775: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 776: "
! 777:
! 778: -- file opened in a+b --
! 779: int(32)
! 780: int(32)
! 781: bool(false)
! 782: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 783: "
! 784:
! 785: -- file opened in a+t --
! 786: int(32)
! 787: int(32)
! 788: bool(false)
! 789: string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 790: "
! 791:
! 792: -- file opened in w+ --
! 793: int(32)
! 794: int(32)
! 795: bool(false)
! 796: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 797: "
! 798:
! 799: -- file opened in w+b --
! 800: int(32)
! 801: int(32)
! 802: bool(false)
! 803: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 804: "
! 805:
! 806: -- file opened in w+t --
! 807: int(32)
! 808: int(32)
! 809: bool(false)
! 810: string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 811: "
! 812:
! 813: -- file opened in x+ --
! 814: int(32)
! 815: int(32)
! 816: bool(false)
! 817: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 818: "
! 819:
! 820: -- file opened in x+b --
! 821: int(32)
! 822: int(32)
! 823: bool(false)
! 824: string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 825: "
! 826:
! 827: -- file opened in x+t --
! 828: int(32)
! 829: int(32)
! 830: bool(false)
! 831: string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
! 832: "
! 833: Done
! 834:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>