Return to strncmp_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test strncmp() function : basic functionality 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: echo "*** Testing strncmp() function: basic functionality ***\n"; 11: 12: echo "-- Testing strncmp() with single quoted string --\n"; 13: var_dump( strncmp('Hello', 'Hello', 5) ); //expected: int(0) 14: var_dump( strncmp('Hello', 'Hi', 5) ); //expected: value < 0 15: var_dump( strncmp('Hi', 'Hello', 5) ); //expected: value > 0 16: 17: echo "-- Testing strncmp() with double quoted string --\n"; 18: var_dump( strncmp("Hello", "Hello", 5) ); //expected: int(0) 19: var_dump( strncmp("Hello", "Hi", 5) ); //expected: value < 0 20: var_dump( strncmp("Hi", "Hello", 5) ); //expected: value > 0 21: 22: echo "-- Testing strncmp() with here-doc string --\n"; 23: $str = <<<HEREDOC 24: Hello 25: HEREDOC; 26: var_dump( strncmp($str, "Hello", 5) ); //expected: int(0) 27: var_dump( strncmp($str, "Hi", 5) ); //expected: value < 0 28: var_dump( strncmp("Hi", $str, 5) ); //expected: value > 0 29: 30: echo "*** Done ***"; 31: ?> 32: --EXPECTREGEX-- 33: \*\*\* Testing strncmp\(\) function: basic functionality \*\*\* 34: -- Testing strncmp\(\) with single quoted string -- 35: int\(0\) 36: int\(-[1-9][0-9]*\) 37: int\([1-9][0-9]*\) 38: -- Testing strncmp\(\) with double quoted string -- 39: int\(0\) 40: int\(-[1-9][0-9]*\) 41: int\([1-9][0-9]*\) 42: -- Testing strncmp\(\) with here-doc string -- 43: int\(0\) 44: int\(-[1-9][0-9]*\) 45: int\([1-9][0-9]*\) 46: \*\*\* Done \*\*\*