Annotation of embedaddon/php/ext/standard/tests/strings/stripos_variation2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test stripos() function : usage variations - single quoted strings for 'haystack' & 'needle' arguments
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : int stripos ( string $haystack, string $needle [, int $offset] );
                      6:  * Description: Find position of first occurrence of a case-insensitive string
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /* Test stripos() function by passing single quoted strings to 'haystack' & 'needle' arguments */
                     11: 
                     12: echo "*** Testing stripos() function: with single quoted strings ***\n";
                     13: $haystack = 'Hello,\t\n\0\n  $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 ';
                     14: $needle = array(
                     15:   //regular strings
                     16:   'l',
                     17:   'L',
                     18:   'HELLO',
                     19:   'hEllo',
                     20: 
                     21:   //escape characters
                     22:   '\t',
                     23:   '\T',
                     24:   '     ',
                     25:   '\n',
                     26:   '\N',
                     27:   '
                     28: ',  //new line
                     29: 
                     30:   //nulls
                     31:   '\0',
                     32:   NULL,
                     33:   null,
                     34: 
                     35:   //boolean false
                     36:   FALSE,
                     37:   false,
                     38: 
                     39:   //empty string
                     40:   '',
                     41: 
                     42:   //special chars
                     43:   ' ',
                     44:   '$',
                     45:   ' $',
                     46:   '&',
                     47:   '!#',
                     48:   '%\o',
                     49:   '\o,',
                     50:   '()',
                     51:   '*+',
                     52:   '+',
                     53:   '-',
                     54:   '.',
                     55:   '.;',
                     56:   '.;',
                     57:   ':;',
                     58:   ';',
                     59:   '<=>',
                     60:   '>',
                     61:   '=>',
                     62:   '?',
                     63:   '@',
                     64:   '@hEllo',
                     65: 
                     66:   '12345', //decimal numeric string
                     67:   '\x23',  //hexadecimal numeric string
                     68:   '#',  //hexadecimal numeric string
                     69:   '\101',  //octal numeric string
                     70:   'A',
                     71:   '456HEE',  //numerics + chars
                     72:   42, //needle as int(ASCII value of '*')
                     73:   $haystack  //haystack as needle
                     74: );
                     75: 
                     76: /* loop through to get the position of the needle in haystack string */
                     77: $count = 1;
                     78: for($index=0; $index<count($needle); $index++) {
                     79:   echo "-- Iteration $count --\n";
                     80:   var_dump( stripos($haystack, $needle[$index]) );
                     81:   var_dump( stripos($haystack, $needle[$index], $index) );
                     82:   $count++;
                     83: }
                     84: echo "*** Done ***";
                     85: ?>
                     86: --EXPECTF--
                     87: *** Testing stripos() function: with single quoted strings ***
                     88: -- Iteration 1 --
                     89: int(2)
                     90: int(2)
                     91: -- Iteration 2 --
                     92: int(2)
                     93: int(2)
                     94: -- Iteration 3 --
                     95: int(0)
                     96: int(38)
                     97: -- Iteration 4 --
                     98: int(0)
                     99: int(38)
                    100: -- Iteration 5 --
                    101: int(6)
                    102: int(6)
                    103: -- Iteration 6 --
                    104: int(6)
                    105: int(6)
                    106: -- Iteration 7 --
                    107: bool(false)
                    108: bool(false)
                    109: -- Iteration 8 --
                    110: int(8)
                    111: int(8)
                    112: -- Iteration 9 --
                    113: int(8)
                    114: int(8)
                    115: -- Iteration 10 --
                    116: bool(false)
                    117: bool(false)
                    118: -- Iteration 11 --
                    119: int(10)
                    120: int(10)
                    121: -- Iteration 12 --
                    122: bool(false)
                    123: bool(false)
                    124: -- Iteration 13 --
                    125: bool(false)
                    126: bool(false)
                    127: -- Iteration 14 --
                    128: bool(false)
                    129: bool(false)
                    130: -- Iteration 15 --
                    131: bool(false)
                    132: bool(false)
                    133: -- Iteration 16 --
                    134: bool(false)
                    135: bool(false)
                    136: -- Iteration 17 --
                    137: int(14)
                    138: int(51)
                    139: -- Iteration 18 --
                    140: int(16)
                    141: bool(false)
                    142: -- Iteration 19 --
                    143: int(15)
                    144: bool(false)
                    145: -- Iteration 20 --
                    146: int(17)
                    147: bool(false)
                    148: -- Iteration 21 --
                    149: int(18)
                    150: bool(false)
                    151: -- Iteration 22 --
                    152: int(20)
                    153: bool(false)
                    154: -- Iteration 23 --
                    155: int(21)
                    156: bool(false)
                    157: -- Iteration 24 --
                    158: int(24)
                    159: int(24)
                    160: -- Iteration 25 --
                    161: int(26)
                    162: int(26)
                    163: -- Iteration 26 --
                    164: int(27)
                    165: int(27)
                    166: -- Iteration 27 --
                    167: int(28)
                    168: int(28)
                    169: -- Iteration 28 --
                    170: int(29)
                    171: int(29)
                    172: -- Iteration 29 --
                    173: bool(false)
                    174: bool(false)
                    175: -- Iteration 30 --
                    176: bool(false)
                    177: bool(false)
                    178: -- Iteration 31 --
                    179: int(31)
                    180: int(31)
                    181: -- Iteration 32 --
                    182: int(32)
                    183: int(32)
                    184: -- Iteration 33 --
                    185: int(33)
                    186: int(33)
                    187: -- Iteration 34 --
                    188: int(35)
                    189: int(35)
                    190: -- Iteration 35 --
                    191: int(34)
                    192: int(34)
                    193: -- Iteration 36 --
                    194: int(36)
                    195: int(36)
                    196: -- Iteration 37 --
                    197: int(37)
                    198: int(37)
                    199: -- Iteration 38 --
                    200: int(37)
                    201: int(37)
                    202: -- Iteration 39 --
                    203: int(43)
                    204: int(43)
                    205: -- Iteration 40 --
                    206: int(52)
                    207: int(52)
                    208: -- Iteration 41 --
                    209: int(19)
                    210: bool(false)
                    211: -- Iteration 42 --
                    212: int(58)
                    213: int(58)
                    214: -- Iteration 43 --
                    215: bool(false)
                    216: bool(false)
                    217: -- Iteration 44 --
                    218: bool(false)
                    219: bool(false)
                    220: -- Iteration 45 --
                    221: int(26)
                    222: bool(false)
                    223: -- Iteration 46 --
                    224: int(0)
                    225: bool(false)
                    226: *** Done ***

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