Annotation of embedaddon/php/ext/standard/tests/file/fgetss_variation2.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test fgetss() function : usage variations - read modes
                      3: --FILE--
                      4: <?php
                      5: /*
                      6:  Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
                      7:  Description: Gets line from file pointer and strip HTML tags
                      8: */
                      9: 
                     10: // include the common file related test functions 
                     11: include ("file.inc");
                     12: 
                     13: /*Test fgetss() with all read modes , reading line by line with allowable tags: <test>, <html>, <?> */
                     14: 
                     15: echo "*** Testing fgetss() : usage variations  ***\n";
                     16: 
                     17: /* string with html and php tags */
                     18: $string_with_tags = <<<EOT
                     19: <test>Testing fgetss() functions</test>
                     20: <?php echo "this string is within php tag"; ?> {;}<{> this
                     21: is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
                     22: <html> html </html> <?php echo "php"; ?>
                     23: this line is without any html and php tags
                     24: this is a line with more than eighty character,want to check line splitting correctly after 80 characters
                     25: this is the text containing \r character 
                     26: this text contains some html tags <body> body </body> <br> br </br>
                     27: this is the line with \n character. 
                     28: EOT;
                     29: 
                     30: $filename = dirname(__FILE__)."/fgetss_variation2.tmp"; 
                     31: 
                     32: /* try reading the file opened in different modes of reading */
                     33: $file_modes = array("r","rb", "rt","r+", "r+b", "r+t");
                     34: 
                     35: for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
                     36:   echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
                     37: 
                     38:   /* create an empty file and write the strings with tags */
                     39:   create_file ($filename); //create an empty file
                     40:   file_put_contents($filename, $string_with_tags); 
                     41:   $file_handle = fopen($filename, $file_modes[$mode_counter]);
                     42:   if(!$file_handle) {
                     43:     echo "Error: failed to open file $filename!\n";
                     44:     exit();
                     45:   }
                     46: 
1.1.1.2 ! misho      47:   // rewind the file pointer to beginning of the file
1.1       misho      48:   var_dump( filesize($filename) );
                     49:   var_dump( rewind($file_handle) );
                     50:   var_dump( ftell($file_handle) );
                     51:   var_dump( feof($file_handle) );
                     52:    
                     53:   /* rewind the file and read the file  line by line with allowable tags */
                     54:   echo "-- Reading line by line with allowable tags: <test>, <html>, <?> --\n";
                     55:   rewind($file_handle);
                     56:   $line = 1;
                     57:   while( !feof($file_handle) ) {
                     58:      echo "-- Line $line --\n"; $line++;
                     59:      var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
                     60:      var_dump( ftell($file_handle) );  // check the file pointer position
                     61:      var_dump( feof($file_handle) );  // check if eof reached
                     62:   }
                     63:  
                     64:   // close the file 
                     65:   fclose($file_handle); 
                     66:   // delete the file 
                     67:   delete_file($filename);
                     68: } // end of for - mode_counter
                     69: 
                     70: echo "Done\n";
                     71: ?>
                     72: --EXPECTF--
                     73: *** Testing fgetss() : usage variations  ***
                     74: 
                     75: -- Testing fgetss() with file opened using r mode --
                     76: int(486)
                     77: bool(true)
                     78: int(0)
                     79: bool(false)
                     80: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                     81: -- Line 1 --
                     82: string(40) "<test>Testing fgetss() functions</test>
                     83: "
                     84: int(40)
                     85: bool(false)
                     86: -- Line 2 --
                     87: string(10) " {;} this
                     88: "
                     89: int(99)
                     90: bool(false)
                     91: -- Line 3 --
                     92: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                     93: "
                     94: int(152)
                     95: bool(false)
                     96: -- Line 4 --
                     97: string(21) "<html> html </html> 
                     98: "
                     99: int(193)
                    100: bool(false)
                    101: -- Line 5 --
                    102: string(43) "this line is without any html and php tags
                    103: "
                    104: int(236)
                    105: bool(false)
                    106: -- Line 6 --
                    107: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    108: int(315)
                    109: bool(false)
                    110: -- Line 7 --
                    111: string(27) "rectly after 80 characters
                    112: "
                    113: int(342)
                    114: bool(false)
                    115: -- Line 8 --
                    116: string(41) "this is the text containing 
 character 
                    117: "
                    118: int(383)
                    119: bool(false)
                    120: -- Line 9 --
                    121: string(46) "this text contains some html tags  body   br 
                    122: "
                    123: int(451)
                    124: bool(false)
                    125: -- Line 10 --
                    126: string(23) "this is the line with 
                    127: "
                    128: int(474)
                    129: bool(false)
                    130: -- Line 11 --
                    131: string(12) " character. "
                    132: int(486)
                    133: bool(true)
                    134: 
                    135: -- Testing fgetss() with file opened using rb mode --
                    136: int(486)
                    137: bool(true)
                    138: int(0)
                    139: bool(false)
                    140: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    141: -- Line 1 --
                    142: string(40) "<test>Testing fgetss() functions</test>
                    143: "
                    144: int(40)
                    145: bool(false)
                    146: -- Line 2 --
                    147: string(10) " {;} this
                    148: "
                    149: int(99)
                    150: bool(false)
                    151: -- Line 3 --
                    152: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    153: "
                    154: int(152)
                    155: bool(false)
                    156: -- Line 4 --
                    157: string(21) "<html> html </html> 
                    158: "
                    159: int(193)
                    160: bool(false)
                    161: -- Line 5 --
                    162: string(43) "this line is without any html and php tags
                    163: "
                    164: int(236)
                    165: bool(false)
                    166: -- Line 6 --
                    167: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    168: int(315)
                    169: bool(false)
                    170: -- Line 7 --
                    171: string(27) "rectly after 80 characters
                    172: "
                    173: int(342)
                    174: bool(false)
                    175: -- Line 8 --
                    176: string(41) "this is the text containing 
 character 
                    177: "
                    178: int(383)
                    179: bool(false)
                    180: -- Line 9 --
                    181: string(46) "this text contains some html tags  body   br 
                    182: "
                    183: int(451)
                    184: bool(false)
                    185: -- Line 10 --
                    186: string(23) "this is the line with 
                    187: "
                    188: int(474)
                    189: bool(false)
                    190: -- Line 11 --
                    191: string(12) " character. "
                    192: int(486)
                    193: bool(true)
                    194: 
                    195: -- Testing fgetss() with file opened using rt mode --
                    196: int(486)
                    197: bool(true)
                    198: int(0)
                    199: bool(false)
                    200: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    201: -- Line 1 --
                    202: string(40) "<test>Testing fgetss() functions</test>
                    203: "
                    204: int(40)
                    205: bool(false)
                    206: -- Line 2 --
                    207: string(10) " {;} this
                    208: "
                    209: int(99)
                    210: bool(false)
                    211: -- Line 3 --
                    212: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    213: "
                    214: int(152)
                    215: bool(false)
                    216: -- Line 4 --
                    217: string(21) "<html> html </html> 
                    218: "
                    219: int(193)
                    220: bool(false)
                    221: -- Line 5 --
                    222: string(43) "this line is without any html and php tags
                    223: "
                    224: int(236)
                    225: bool(false)
                    226: -- Line 6 --
                    227: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    228: int(315)
                    229: bool(false)
                    230: -- Line 7 --
                    231: string(27) "rectly after 80 characters
                    232: "
                    233: int(342)
                    234: bool(false)
                    235: -- Line 8 --
                    236: string(41) "this is the text containing 
 character 
                    237: "
                    238: int(383)
                    239: bool(false)
                    240: -- Line 9 --
                    241: string(46) "this text contains some html tags  body   br 
                    242: "
                    243: int(451)
                    244: bool(false)
                    245: -- Line 10 --
                    246: string(23) "this is the line with 
                    247: "
                    248: int(474)
                    249: bool(false)
                    250: -- Line 11 --
                    251: string(12) " character. "
                    252: int(486)
                    253: bool(true)
                    254: 
                    255: -- Testing fgetss() with file opened using r+ mode --
                    256: int(486)
                    257: bool(true)
                    258: int(0)
                    259: bool(false)
                    260: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    261: -- Line 1 --
                    262: string(40) "<test>Testing fgetss() functions</test>
                    263: "
                    264: int(40)
                    265: bool(false)
                    266: -- Line 2 --
                    267: string(10) " {;} this
                    268: "
                    269: int(99)
                    270: bool(false)
                    271: -- Line 3 --
                    272: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    273: "
                    274: int(152)
                    275: bool(false)
                    276: -- Line 4 --
                    277: string(21) "<html> html </html> 
                    278: "
                    279: int(193)
                    280: bool(false)
                    281: -- Line 5 --
                    282: string(43) "this line is without any html and php tags
                    283: "
                    284: int(236)
                    285: bool(false)
                    286: -- Line 6 --
                    287: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    288: int(315)
                    289: bool(false)
                    290: -- Line 7 --
                    291: string(27) "rectly after 80 characters
                    292: "
                    293: int(342)
                    294: bool(false)
                    295: -- Line 8 --
                    296: string(41) "this is the text containing 
 character 
                    297: "
                    298: int(383)
                    299: bool(false)
                    300: -- Line 9 --
                    301: string(46) "this text contains some html tags  body   br 
                    302: "
                    303: int(451)
                    304: bool(false)
                    305: -- Line 10 --
                    306: string(23) "this is the line with 
                    307: "
                    308: int(474)
                    309: bool(false)
                    310: -- Line 11 --
                    311: string(12) " character. "
                    312: int(486)
                    313: bool(true)
                    314: 
                    315: -- Testing fgetss() with file opened using r+b mode --
                    316: int(486)
                    317: bool(true)
                    318: int(0)
                    319: bool(false)
                    320: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    321: -- Line 1 --
                    322: string(40) "<test>Testing fgetss() functions</test>
                    323: "
                    324: int(40)
                    325: bool(false)
                    326: -- Line 2 --
                    327: string(10) " {;} this
                    328: "
                    329: int(99)
                    330: bool(false)
                    331: -- Line 3 --
                    332: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    333: "
                    334: int(152)
                    335: bool(false)
                    336: -- Line 4 --
                    337: string(21) "<html> html </html> 
                    338: "
                    339: int(193)
                    340: bool(false)
                    341: -- Line 5 --
                    342: string(43) "this line is without any html and php tags
                    343: "
                    344: int(236)
                    345: bool(false)
                    346: -- Line 6 --
                    347: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    348: int(315)
                    349: bool(false)
                    350: -- Line 7 --
                    351: string(27) "rectly after 80 characters
                    352: "
                    353: int(342)
                    354: bool(false)
                    355: -- Line 8 --
                    356: string(41) "this is the text containing 
 character 
                    357: "
                    358: int(383)
                    359: bool(false)
                    360: -- Line 9 --
                    361: string(46) "this text contains some html tags  body   br 
                    362: "
                    363: int(451)
                    364: bool(false)
                    365: -- Line 10 --
                    366: string(23) "this is the line with 
                    367: "
                    368: int(474)
                    369: bool(false)
                    370: -- Line 11 --
                    371: string(12) " character. "
                    372: int(486)
                    373: bool(true)
                    374: 
                    375: -- Testing fgetss() with file opened using r+t mode --
                    376: int(486)
                    377: bool(true)
                    378: int(0)
                    379: bool(false)
                    380: -- Reading line by line with allowable tags: <test>, <html>, <?> --
                    381: -- Line 1 --
                    382: string(40) "<test>Testing fgetss() functions</test>
                    383: "
                    384: int(40)
                    385: bool(false)
                    386: -- Line 2 --
                    387: string(10) " {;} this
                    388: "
                    389: int(99)
                    390: bool(false)
                    391: -- Line 3 --
                    392: string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
                    393: "
                    394: int(152)
                    395: bool(false)
                    396: -- Line 4 --
                    397: string(21) "<html> html </html> 
                    398: "
                    399: int(193)
                    400: bool(false)
                    401: -- Line 5 --
                    402: string(43) "this line is without any html and php tags
                    403: "
                    404: int(236)
                    405: bool(false)
                    406: -- Line 6 --
                    407: string(79) "this is a line with more than eighty character,want to check line splitting cor"
                    408: int(315)
                    409: bool(false)
                    410: -- Line 7 --
                    411: string(27) "rectly after 80 characters
                    412: "
                    413: int(342)
                    414: bool(false)
                    415: -- Line 8 --
                    416: string(41) "this is the text containing 
 character 
                    417: "
                    418: int(383)
                    419: bool(false)
                    420: -- Line 9 --
                    421: string(46) "this text contains some html tags  body   br 
                    422: "
                    423: int(451)
                    424: bool(false)
                    425: -- Line 10 --
                    426: string(23) "this is the line with 
                    427: "
                    428: int(474)
                    429: bool(false)
                    430: -- Line 11 --
                    431: string(12) " character. "
                    432: int(486)
                    433: bool(true)
                    434: Done

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