Annotation of embedaddon/php/ext/standard/tests/file/fgetss_variation3-win32.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test fgetss() function : usage variations - read/write modes 
                      3: --SKIPIF--
                      4: <?php
                      5: if (substr(PHP_OS, 0, 3) != 'WIN') {
                      6:     die('skip.. only valid for Windows');
                      7: }
                      8: ?>
                      9: --FILE--
                     10: <?php
                     11: /*
                     12:  Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
                     13:  Description: Gets line from file pointer and strip HTML tags
                     14: */
                     15: 
                     16: /* try fgetss on files which are opened in read/write modes
                     17:     w+, w+b, w+t,
                     18:     a+, a+b, a+t,
                     19:     x+, x+b, x+t
                     20:  reading line by line with allowable tags: <test>, <html>, <?>
                     21: */
                     22: 
                     23: 
                     24: echo "*** Testing fgetss() : usage variations ***\n";
                     25: 
                     26: /* string with html and php tags */
                     27: $string_with_tags = <<<EOT
                     28: <test>Testing fgetss() functions</test>
                     29: <?php echo "this string is within php tag"; ?> {;}<{> this
                     30: is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
                     31: <html> html </html> <?php echo "php"; ?>
                     32: this line is without any html and php tags
                     33: this is a line with more than eighty character,want to check line splitting correctly after 80 characters
                     34: this text contains some html tags <body> body </body> <br> br </br>
                     35: this is the line with \n character. 
                     36: EOT;
                     37: 
                     38: if(substr(PHP_OS, 0, 3) == "WIN")  {
                     39:        $string_with_tags = str_replace("\r",'', $string_with_tags);
                     40: }
                     41: 
                     42: $filename = dirname(__FILE__)."/fgetss_variation3.tmp"; 
                     43: 
                     44: /* try reading the file opened in different modes of reading */
                     45: $file_modes = array("w+","w+b", "w+t","a+", "a+b", "a+t","x+","x+b","x+t");
                     46: 
                     47: for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
                     48:   echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
                     49: 
                     50:   /* create an empty file and write the strings with tags */
                     51:   $file_handle = fopen($filename, $file_modes[$mode_counter]);
                     52:   fwrite($file_handle,$string_with_tags); //writing data to the file
                     53:   if(!$file_handle) {
                     54:     echo "Error: failed to open file $filename!\n";
                     55:     exit();
                     56:   }
                     57:   
                     58:   // rewind the file pointer to begining of the file
                     59:   rewind($file_handle);
                     60:   var_dump( ftell($file_handle) );
                     61:   var_dump( filesize($filename) );
                     62:   var_dump( feof($file_handle) );
                     63: 
                     64:   /* rewind the file and read the file  line by line with allowable tags */
                     65:   echo "-- Reading line by line with allowable tags: <test>, <html>, <?> --\n";
                     66:   $line = 1;
                     67:   while( !feof($file_handle) ) {
                     68:      echo "-- Line $line --\n"; $line++;
                     69:      var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
                     70:      var_dump( ftell($file_handle) );  // check the file pointer position
                     71:      var_dump( feof($file_handle) );  // check if eof reached
                     72:   }
                     73:  
                     74:   // close the file 
                     75:   fclose($file_handle);
                     76:    
                     77:   // delete the file 
                     78:   unlink($filename);
                     79: } // end of for - mode_counter
                     80: 
                     81: echo "Done\n";
                     82: ?>
                     83: --EXPECT--
                     84: *** Testing fgetss() : usage variations ***
                     85: 
                     86: -- Testing fgetss() with file opened using w+ mode --
                     87: int(0)
                     88: int(445)
                     89: bool(false)
                     90: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                     91: -- Line 1 --
                     92: string(40) "<test>Testing fgetss() functions</test>
                     93: "
                     94: int(40)
                     95: bool(false)
                     96: -- Line 2 --
                     97: string(10) " {;} this
                     98: "
                     99: int(99)
                    100: bool(false)
                    101: -- Line 3 --
                    102: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    103: "
                    104: int(152)
                    105: bool(false)
                    106: -- Line 4 --
                    107: string(21) "<html> html </html> 
                    108: "
                    109: int(193)
                    110: bool(false)
                    111: -- Line 5 --
                    112: string(43) "this line is without any html and php tags
                    113: "
                    114: int(236)
                    115: bool(false)
                    116: -- Line 6 --
                    117: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    118: int(315)
                    119: bool(false)
                    120: -- Line 7 --
                    121: string(27) "rectly after 80 characters
                    122: "
                    123: int(342)
                    124: bool(false)
                    125: -- Line 8 --
                    126: string(46) "this text contains some html tags  body   br 
                    127: "
                    128: int(410)
                    129: bool(false)
                    130: -- Line 9 --
                    131: string(23) "this is the line with 
                    132: "
                    133: int(433)
                    134: bool(false)
                    135: -- Line 10 --
                    136: string(12) " character. "
                    137: int(445)
                    138: bool(true)
                    139: 
                    140: -- Testing fgetss() with file opened using w+b mode --
                    141: int(0)
                    142: int(445)
                    143: bool(false)
                    144: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    145: -- Line 1 --
                    146: string(40) "<test>Testing fgetss() functions</test>
                    147: "
                    148: int(40)
                    149: bool(false)
                    150: -- Line 2 --
                    151: string(10) " {;} this
                    152: "
                    153: int(99)
                    154: bool(false)
                    155: -- Line 3 --
                    156: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    157: "
                    158: int(152)
                    159: bool(false)
                    160: -- Line 4 --
                    161: string(21) "<html> html </html> 
                    162: "
                    163: int(193)
                    164: bool(false)
                    165: -- Line 5 --
                    166: string(43) "this line is without any html and php tags
                    167: "
                    168: int(236)
                    169: bool(false)
                    170: -- Line 6 --
                    171: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    172: int(315)
                    173: bool(false)
                    174: -- Line 7 --
                    175: string(27) "rectly after 80 characters
                    176: "
                    177: int(342)
                    178: bool(false)
                    179: -- Line 8 --
                    180: string(46) "this text contains some html tags  body   br 
                    181: "
                    182: int(410)
                    183: bool(false)
                    184: -- Line 9 --
                    185: string(23) "this is the line with 
                    186: "
                    187: int(433)
                    188: bool(false)
                    189: -- Line 10 --
                    190: string(12) " character. "
                    191: int(445)
                    192: bool(true)
                    193: 
                    194: -- Testing fgetss() with file opened using w+t mode --
                    195: int(0)
                    196: int(453)
                    197: bool(false)
                    198: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    199: -- Line 1 --
                    200: string(40) "<test>Testing fgetss() functions</test>
                    201: "
                    202: int(40)
                    203: bool(false)
                    204: -- Line 2 --
                    205: string(10) " {;} this
                    206: "
                    207: int(99)
                    208: bool(false)
                    209: -- Line 3 --
                    210: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    211: "
                    212: int(152)
                    213: bool(false)
                    214: -- Line 4 --
                    215: string(21) "<html> html </html> 
                    216: "
                    217: int(193)
                    218: bool(false)
                    219: -- Line 5 --
                    220: string(43) "this line is without any html and php tags
                    221: "
                    222: int(236)
                    223: bool(false)
                    224: -- Line 6 --
                    225: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    226: int(315)
                    227: bool(false)
                    228: -- Line 7 --
                    229: string(27) "rectly after 80 characters
                    230: "
                    231: int(342)
                    232: bool(false)
                    233: -- Line 8 --
                    234: string(46) "this text contains some html tags  body   br 
                    235: "
                    236: int(410)
                    237: bool(false)
                    238: -- Line 9 --
                    239: string(23) "this is the line with 
                    240: "
                    241: int(433)
                    242: bool(false)
                    243: -- Line 10 --
                    244: string(12) " character. "
                    245: int(445)
                    246: bool(true)
                    247: 
                    248: -- Testing fgetss() with file opened using a+ mode --
                    249: int(0)
                    250: int(445)
                    251: bool(false)
                    252: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    253: -- Line 1 --
                    254: string(40) "<test>Testing fgetss() functions</test>
                    255: "
                    256: int(40)
                    257: bool(false)
                    258: -- Line 2 --
                    259: string(10) " {;} this
                    260: "
                    261: int(99)
                    262: bool(false)
                    263: -- Line 3 --
                    264: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    265: "
                    266: int(152)
                    267: bool(false)
                    268: -- Line 4 --
                    269: string(21) "<html> html </html> 
                    270: "
                    271: int(193)
                    272: bool(false)
                    273: -- Line 5 --
                    274: string(43) "this line is without any html and php tags
                    275: "
                    276: int(236)
                    277: bool(false)
                    278: -- Line 6 --
                    279: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    280: int(315)
                    281: bool(false)
                    282: -- Line 7 --
                    283: string(27) "rectly after 80 characters
                    284: "
                    285: int(342)
                    286: bool(false)
                    287: -- Line 8 --
                    288: string(46) "this text contains some html tags  body   br 
                    289: "
                    290: int(410)
                    291: bool(false)
                    292: -- Line 9 --
                    293: string(23) "this is the line with 
                    294: "
                    295: int(433)
                    296: bool(false)
                    297: -- Line 10 --
                    298: string(12) " character. "
                    299: int(445)
                    300: bool(true)
                    301: 
                    302: -- Testing fgetss() with file opened using a+b mode --
                    303: int(0)
                    304: int(445)
                    305: bool(false)
                    306: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    307: -- Line 1 --
                    308: string(40) "<test>Testing fgetss() functions</test>
                    309: "
                    310: int(40)
                    311: bool(false)
                    312: -- Line 2 --
                    313: string(10) " {;} this
                    314: "
                    315: int(99)
                    316: bool(false)
                    317: -- Line 3 --
                    318: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    319: "
                    320: int(152)
                    321: bool(false)
                    322: -- Line 4 --
                    323: string(21) "<html> html </html> 
                    324: "
                    325: int(193)
                    326: bool(false)
                    327: -- Line 5 --
                    328: string(43) "this line is without any html and php tags
                    329: "
                    330: int(236)
                    331: bool(false)
                    332: -- Line 6 --
                    333: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    334: int(315)
                    335: bool(false)
                    336: -- Line 7 --
                    337: string(27) "rectly after 80 characters
                    338: "
                    339: int(342)
                    340: bool(false)
                    341: -- Line 8 --
                    342: string(46) "this text contains some html tags  body   br 
                    343: "
                    344: int(410)
                    345: bool(false)
                    346: -- Line 9 --
                    347: string(23) "this is the line with 
                    348: "
                    349: int(433)
                    350: bool(false)
                    351: -- Line 10 --
                    352: string(12) " character. "
                    353: int(445)
                    354: bool(true)
                    355: 
                    356: -- Testing fgetss() with file opened using a+t mode --
                    357: int(0)
                    358: int(453)
                    359: bool(false)
                    360: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    361: -- Line 1 --
                    362: string(40) "<test>Testing fgetss() functions</test>
                    363: "
                    364: int(40)
                    365: bool(false)
                    366: -- Line 2 --
                    367: string(10) " {;} this
                    368: "
                    369: int(99)
                    370: bool(false)
                    371: -- Line 3 --
                    372: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    373: "
                    374: int(152)
                    375: bool(false)
                    376: -- Line 4 --
                    377: string(21) "<html> html </html> 
                    378: "
                    379: int(193)
                    380: bool(false)
                    381: -- Line 5 --
                    382: string(43) "this line is without any html and php tags
                    383: "
                    384: int(236)
                    385: bool(false)
                    386: -- Line 6 --
                    387: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    388: int(315)
                    389: bool(false)
                    390: -- Line 7 --
                    391: string(27) "rectly after 80 characters
                    392: "
                    393: int(342)
                    394: bool(false)
                    395: -- Line 8 --
                    396: string(46) "this text contains some html tags  body   br 
                    397: "
                    398: int(410)
                    399: bool(false)
                    400: -- Line 9 --
                    401: string(23) "this is the line with 
                    402: "
                    403: int(433)
                    404: bool(false)
                    405: -- Line 10 --
                    406: string(12) " character. "
                    407: int(445)
                    408: bool(true)
                    409: 
                    410: -- Testing fgetss() with file opened using x+ mode --
                    411: int(0)
                    412: int(445)
                    413: bool(false)
                    414: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    415: -- Line 1 --
                    416: string(40) "<test>Testing fgetss() functions</test>
                    417: "
                    418: int(40)
                    419: bool(false)
                    420: -- Line 2 --
                    421: string(10) " {;} this
                    422: "
                    423: int(99)
                    424: bool(false)
                    425: -- Line 3 --
                    426: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    427: "
                    428: int(152)
                    429: bool(false)
                    430: -- Line 4 --
                    431: string(21) "<html> html </html> 
                    432: "
                    433: int(193)
                    434: bool(false)
                    435: -- Line 5 --
                    436: string(43) "this line is without any html and php tags
                    437: "
                    438: int(236)
                    439: bool(false)
                    440: -- Line 6 --
                    441: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    442: int(315)
                    443: bool(false)
                    444: -- Line 7 --
                    445: string(27) "rectly after 80 characters
                    446: "
                    447: int(342)
                    448: bool(false)
                    449: -- Line 8 --
                    450: string(46) "this text contains some html tags  body   br 
                    451: "
                    452: int(410)
                    453: bool(false)
                    454: -- Line 9 --
                    455: string(23) "this is the line with 
                    456: "
                    457: int(433)
                    458: bool(false)
                    459: -- Line 10 --
                    460: string(12) " character. "
                    461: int(445)
                    462: bool(true)
                    463: 
                    464: -- Testing fgetss() with file opened using x+b mode --
                    465: int(0)
                    466: int(445)
                    467: bool(false)
                    468: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    469: -- Line 1 --
                    470: string(40) "<test>Testing fgetss() functions</test>
                    471: "
                    472: int(40)
                    473: bool(false)
                    474: -- Line 2 --
                    475: string(10) " {;} this
                    476: "
                    477: int(99)
                    478: bool(false)
                    479: -- Line 3 --
                    480: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    481: "
                    482: int(152)
                    483: bool(false)
                    484: -- Line 4 --
                    485: string(21) "<html> html </html> 
                    486: "
                    487: int(193)
                    488: bool(false)
                    489: -- Line 5 --
                    490: string(43) "this line is without any html and php tags
                    491: "
                    492: int(236)
                    493: bool(false)
                    494: -- Line 6 --
                    495: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    496: int(315)
                    497: bool(false)
                    498: -- Line 7 --
                    499: string(27) "rectly after 80 characters
                    500: "
                    501: int(342)
                    502: bool(false)
                    503: -- Line 8 --
                    504: string(46) "this text contains some html tags  body   br 
                    505: "
                    506: int(410)
                    507: bool(false)
                    508: -- Line 9 --
                    509: string(23) "this is the line with 
                    510: "
                    511: int(433)
                    512: bool(false)
                    513: -- Line 10 --
                    514: string(12) " character. "
                    515: int(445)
                    516: bool(true)
                    517: 
                    518: -- Testing fgetss() with file opened using x+t mode --
                    519: int(0)
                    520: int(453)
                    521: bool(false)
                    522: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    523: -- Line 1 --
                    524: string(40) "<test>Testing fgetss() functions</test>
                    525: "
                    526: int(40)
                    527: bool(false)
                    528: -- Line 2 --
                    529: string(10) " {;} this
                    530: "
                    531: int(99)
                    532: bool(false)
                    533: -- Line 3 --
                    534: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    535: "
                    536: int(152)
                    537: bool(false)
                    538: -- Line 4 --
                    539: string(21) "<html> html </html> 
                    540: "
                    541: int(193)
                    542: bool(false)
                    543: -- Line 5 --
                    544: string(43) "this line is without any html and php tags
                    545: "
                    546: int(236)
                    547: bool(false)
                    548: -- Line 6 --
                    549: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    550: int(315)
                    551: bool(false)
                    552: -- Line 7 --
                    553: string(27) "rectly after 80 characters
                    554: "
                    555: int(342)
                    556: bool(false)
                    557: -- Line 8 --
                    558: string(46) "this text contains some html tags  body   br 
                    559: "
                    560: int(410)
                    561: bool(false)
                    562: -- Line 9 --
                    563: string(23) "this is the line with 
                    564: "
                    565: int(433)
                    566: bool(false)
                    567: -- Line 10 --
                    568: string(12) " character. "
                    569: int(445)
                    570: bool(true)
                    571: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>