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

1.1       misho       1: --TEST--
                      2: Test strrpos() function : usage variations - checking binary safe with 'haystack' argument
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : int strrpos ( string $haystack, string $needle [, int $offset] );
                      6:  * Description: Find position of last occurrence of 'needle' in 'haystack'.
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /* Test strrpos() function with null terminated strings for 'haystack' argument 
                     11:  *  in order to check the binary safe 
                     12: */
                     13: 
                     14: echo "*** Test strrpos() function: binary safe ***\n";
                     15: $haystacks = array(
                     16:   "Hello".chr(0)."World",
                     17:   chr(0)."Hello World",
                     18:   "Hello World".chr(0),
                     19:   chr(0).chr(0).chr(0),
                     20:   "Hello\0world",
                     21:   "\0Hello",
                     22:   "Hello\0"
                     23: );
                     24: 
                     25: for($index = 0; $index < count($haystacks); $index++ ) {
                     26:   var_dump( strrpos($haystacks[$index], "\0") );
                     27:   var_dump( strrpos($haystacks[$index], "\0", $index) );
                     28: }
                     29: echo "*** Done ***";
                     30: ?>
                     31: --EXPECTF--
                     32: *** Test strrpos() function: binary safe ***
                     33: int(5)
                     34: int(5)
                     35: int(0)
                     36: bool(false)
                     37: int(11)
                     38: int(11)
                     39: int(2)
                     40: bool(false)
                     41: int(5)
                     42: int(5)
                     43: int(0)
                     44: bool(false)
                     45: int(5)
                     46: bool(false)
                     47: *** Done ***

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