Return to strncmp_variation3.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test strncmp() function: usage variations - different lengths 3: --FILE-- 4: <?php 5: /* Prototype : int strncmp ( string $str1, string $str2, int $len ); 6: * Description: Binary safe case-sensitive string comparison of the first n characters 7: * Source code: Zend/zend_builtin_functions.c 8: */ 9: 10: /* Test strncmp() with various lengths */ 11: 12: echo "*** Test strncmp() function: with different lengths ***\n"; 13: /* definitions of required variables */ 14: $str1 = "Hello, World\n"; 15: $str2 = "Hello, world\n"; 16: 17: /* loop through to compare the strings, for various length values */ 18: for($len = strlen($str1); $len >= 0; $len--) { 19: var_dump( strncmp($str1, $str2, $len) ); 20: } 21: echo "*** Done ***\n"; 22: ?> 23: --EXPECTREGEX-- 24: \*\*\* Test strncmp\(\) function: with different lengths \*\*\* 25: int\(-[1-9][0-9]*\) 26: int\(-[1-9][0-9]*\) 27: int\(-[1-9][0-9]*\) 28: int\(-[1-9][0-9]*\) 29: int\(-[1-9][0-9]*\) 30: int\(-[1-9][0-9]*\) 31: int\(0\) 32: int\(0\) 33: int\(0\) 34: int\(0\) 35: int\(0\) 36: int\(0\) 37: int\(0\) 38: int\(0\) 39: \*\*\* Done \*\*\*