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

1.1       misho       1: --TEST--
                      2: Test stripos() function : usage variations - double 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 double quoted strings for 'haystack' & 'needle' arguments */
                     11: 
                     12: echo "*** Testing stripos() function: with double 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",  //invalid input
                     24:   "     ",
                     25:   "\n",
                     26:   "\N",  //invalid input
                     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:   "@hEllo",
                     64: 
                     65:   "12345", //decimal numeric string
                     66:   "\x23",  //hexadecimal numeric string
                     67:   "#",  //respective ASCII char of \x23
                     68:   "\101",  //octal numeric string
                     69:   "A",  //respective ASCII char of \101
                     70:   "456HEE",  //numerics + chars
                     71:   $haystack  //haystack as needle
                     72: );
                     73:  
                     74: /* loop through to get the position of the needle in haystack string */
                     75: $count = 1;
                     76: for($index=0; $index<count($needle); $index++) {
                     77:   echo "-- Iteration $count --\n";
                     78:   var_dump( stripos($haystack, $needle[$index]) );
                     79:   var_dump( stripos($haystack, $needle[$index], $index) );
                     80:   $count++;
                     81: }
                     82: echo "*** Done ***";
                     83: ?>
                     84: --EXPECTF--
                     85: *** Testing stripos() function: with double quoted strings ***
                     86: -- Iteration 1 --
                     87: int(2)
                     88: int(2)
                     89: -- Iteration 2 --
                     90: int(2)
                     91: int(2)
                     92: -- Iteration 3 --
                     93: int(0)
                     94: int(34)
                     95: -- Iteration 4 --
                     96: int(0)
                     97: int(34)
                     98: -- Iteration 5 --
                     99: int(6)
                    100: int(6)
                    101: -- Iteration 6 --
                    102: bool(false)
                    103: bool(false)
                    104: -- Iteration 7 --
                    105: bool(false)
                    106: bool(false)
                    107: -- Iteration 8 --
                    108: int(7)
                    109: int(7)
                    110: -- Iteration 9 --
                    111: bool(false)
                    112: bool(false)
                    113: -- Iteration 10 --
                    114: int(7)
                    115: int(9)
                    116: -- Iteration 11 --
                    117: int(8)
                    118: bool(false)
                    119: -- Iteration 12 --
                    120: int(8)
                    121: bool(false)
                    122: -- Iteration 13 --
                    123: int(8)
                    124: bool(false)
                    125: -- Iteration 14 --
                    126: int(8)
                    127: bool(false)
                    128: -- Iteration 15 --
                    129: int(8)
                    130: bool(false)
                    131: -- Iteration 16 --
                    132: bool(false)
                    133: bool(false)
                    134: -- Iteration 17 --
                    135: int(10)
                    136: int(47)
                    137: -- Iteration 18 --
                    138: int(12)
                    139: bool(false)
                    140: -- Iteration 19 --
                    141: int(11)
                    142: bool(false)
                    143: -- Iteration 20 --
                    144: int(13)
                    145: bool(false)
                    146: -- Iteration 21 --
                    147: int(14)
                    148: bool(false)
                    149: -- Iteration 22 --
                    150: int(16)
                    151: bool(false)
                    152: -- Iteration 23 --
                    153: int(17)
                    154: bool(false)
                    155: -- Iteration 24 --
                    156: int(20)
                    157: bool(false)
                    158: -- Iteration 25 --
                    159: int(22)
                    160: bool(false)
                    161: -- Iteration 26 --
                    162: int(23)
                    163: bool(false)
                    164: -- Iteration 27 --
                    165: int(24)
                    166: bool(false)
                    167: -- Iteration 28 --
                    168: int(25)
                    169: bool(false)
                    170: -- Iteration 29 --
                    171: bool(false)
                    172: bool(false)
                    173: -- Iteration 30 --
                    174: int(27)
                    175: bool(false)
                    176: -- Iteration 31 --
                    177: int(28)
                    178: bool(false)
                    179: -- Iteration 32 --
                    180: int(29)
                    181: bool(false)
                    182: -- Iteration 33 --
                    183: int(31)
                    184: bool(false)
                    185: -- Iteration 34 --
                    186: int(30)
                    187: bool(false)
                    188: -- Iteration 35 --
                    189: int(32)
                    190: bool(false)
                    191: -- Iteration 36 --
                    192: int(33)
                    193: bool(false)
                    194: -- Iteration 37 --
                    195: int(33)
                    196: bool(false)
                    197: -- Iteration 38 --
                    198: int(39)
                    199: int(39)
                    200: -- Iteration 39 --
                    201: int(15)
                    202: int(48)
                    203: -- Iteration 40 --
                    204: int(15)
                    205: int(48)
                    206: -- Iteration 41 --
                    207: int(51)
                    208: int(51)
                    209: -- Iteration 42 --
                    210: int(51)
                    211: int(51)
                    212: -- Iteration 43 --
                    213: bool(false)
                    214: bool(false)
                    215: -- Iteration 44 --
                    216: int(0)
                    217: bool(false)
                    218: *** Done ***

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