Return to strncmp_variation8.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 - single quoted strings 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() function with single quoted strings for 'str1', 'str2' */ 11: 12: echo "*** Test strncmp() function: with single quoted strings ***\n"; 13: $strings = array( 14: 'Hello, World', 15: 'hello, world', 16: 'HELLO, WORLD', 17: 'Hello, World\n' 18: ); 19: /* loop through to compare each string with the other string */ 20: $count = 1; 21: for($index1 = 0; $index1 < count($strings); $index1++) { 22: echo "-- Iteration $count --\n"; 23: for($index2 = 0; $index2 < count($strings); $index2++) { 24: var_dump( strncmp( $strings[$index1], $strings[$index2], (strlen($strings[$index1]) + 1) ) ); 25: } 26: $count ++; 27: } 28: echo "*** Done ***\n"; 29: ?> 30: --EXPECTREGEX-- 31: \*\*\* Test strncmp\(\) function: with single quoted strings \*\*\* 32: -- Iteration 1 -- 33: int\(0\) 34: int\(-[1-9][0-9]*\) 35: int\([1-9][0-9]*\) 36: int\(-[1-9][0-9]*\) 37: -- Iteration 2 -- 38: int\([1-9][0-9]*\) 39: int\(0\) 40: int\([1-9][0-9]*\) 41: int\([1-9][0-9]*\) 42: -- Iteration 3 -- 43: int\(-[1-9][0-9]*\) 44: int\(-[1-9][0-9]*\) 45: int\(0\) 46: int\(-[1-9][0-9]*\) 47: -- Iteration 4 -- 48: int\([1-9][0-9]*\) 49: int\(-[1-9][0-9]*\) 50: int\([1-9][0-9]*\) 51: int\(0\) 52: \*\*\* Done \*\*\*