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

1.1       misho       1: --TEST--
                      2: Test strtok() function : usage variations - with embedded nulls in the strings
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string strtok ( str $str, str $token )
                      6:  * Description: splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /*
                     11:  * Testing strtok() : with embedded nulls in the strings
                     12: */
                     13: 
                     14: echo "*** Testing strtok() : with embedded nulls in the strings ***\n";
                     15: 
                     16: // defining varous strings with embedded nulls
                     17: $strings_with_nulls = array(
                     18:                           "\0",
                     19:                           '\0',
                     20:                            "hello\0world",
                     21:                            "\0hel\0lo",
                     22:                            "hello\0",
                     23:                            "\0\0hello\tworld\0\0",
                     24:                            "\\0he\0llo\\0",
                     25:                            'hello\0\0'
                     26:                            );
                     27: 
                     28: // loop through each element of the array and check the working of strtok()
                     29: // when supplied with different string values
                     30: 
                     31: $counter = 1;
                     32: foreach( $strings_with_nulls as $string )  {
                     33:   echo "\n--- Iteration $counter ---\n";
                     34:   var_dump( strtok($string, "\0") );
                     35:   for($count = 1; $count <= 5; $count++)  {
                     36:     var_dump( strtok("\0") );
                     37:   }
                     38:   $counter++;
                     39: }
                     40: 
                     41: 
                     42: echo "Done\n";
                     43: ?>
                     44: --EXPECTF--
                     45: *** Testing strtok() : with embedded nulls in the strings ***
                     46: 
                     47: --- Iteration 1 ---
                     48: bool(false)
                     49: bool(false)
                     50: bool(false)
                     51: bool(false)
                     52: bool(false)
                     53: bool(false)
                     54: 
                     55: --- Iteration 2 ---
                     56: string(2) "\0"
                     57: bool(false)
                     58: bool(false)
                     59: bool(false)
                     60: bool(false)
                     61: bool(false)
                     62: 
                     63: --- Iteration 3 ---
                     64: string(5) "hello"
                     65: string(5) "world"
                     66: bool(false)
                     67: bool(false)
                     68: bool(false)
                     69: bool(false)
                     70: 
                     71: --- Iteration 4 ---
                     72: string(3) "hel"
                     73: string(2) "lo"
                     74: bool(false)
                     75: bool(false)
                     76: bool(false)
                     77: bool(false)
                     78: 
                     79: --- Iteration 5 ---
                     80: string(5) "hello"
                     81: bool(false)
                     82: bool(false)
                     83: bool(false)
                     84: bool(false)
                     85: bool(false)
                     86: 
                     87: --- Iteration 6 ---
                     88: string(11) "hello      world"
                     89: bool(false)
                     90: bool(false)
                     91: bool(false)
                     92: bool(false)
                     93: bool(false)
                     94: 
                     95: --- Iteration 7 ---
                     96: string(4) "\0he"
                     97: string(5) "llo\0"
                     98: bool(false)
                     99: bool(false)
                    100: bool(false)
                    101: bool(false)
                    102: 
                    103: --- Iteration 8 ---
                    104: string(9) "hello\0\0"
                    105: bool(false)
                    106: bool(false)
                    107: bool(false)
                    108: bool(false)
                    109: bool(false)
                    110: Done

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