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

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

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