Annotation of embedaddon/php/ext/standard/tests/strings/strtok_basic.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test strtok() function : basic functionality
! 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() : basic functionality
! 12: */
! 13:
! 14: echo "*** Testing strtok() : basic functionality ***\n";
! 15:
! 16: // Initialize all required variables
! 17: $str = 'This testcase test strtok() function.';
! 18: $token = ' ().';
! 19:
! 20: echo "\nThe Input string is:\n\"$str\"\n";
! 21: echo "\nThe token string is:\n\"$token\"\n";
! 22:
! 23: // using strtok() with $str argument
! 24: echo "\n--- Token 1 ---\n";
! 25: var_dump( strtok($str, $token) );
! 26:
! 27: for( $i = 2; $i <=7; $i++ ) {
! 28: echo "\n--- Token $i ---\n";
! 29: var_dump( strtok($token) );
! 30: }
! 31:
! 32: echo "Done\n";
! 33: ?>
! 34: --EXPECTF--
! 35: *** Testing strtok() : basic functionality ***
! 36:
! 37: The Input string is:
! 38: "This testcase test strtok() function."
! 39:
! 40: The token string is:
! 41: " ()."
! 42:
! 43: --- Token 1 ---
! 44: string(4) "This"
! 45:
! 46: --- Token 2 ---
! 47: string(8) "testcase"
! 48:
! 49: --- Token 3 ---
! 50: string(4) "test"
! 51:
! 52: --- Token 4 ---
! 53: string(6) "strtok"
! 54:
! 55: --- Token 5 ---
! 56: string(8) "function"
! 57:
! 58: --- Token 6 ---
! 59: bool(false)
! 60:
! 61: --- Token 7 ---
! 62: bool(false)
! 63: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>