Annotation of embedaddon/php/ext/standard/tests/strings/strncmp_variation9.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strncmp() function: usage variations - different inputs(heredoc 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 different strings for 'str1', 'str2' and considering case sensitive */
11:
12: echo "*** Test strncmp() function: with different input strings ***\n";
13:
14: /* heredoc string */
15: $str1 = <<<EOD
16: Example of string
17: spanning multiple lines
18: using heredoc syntax.
19: EOD;
20:
21: /* identifier name contains underscore */
22: $str2 = <<<identifier_str2
23: Example of heredoc
24: string, whose identifier
25: having underscore("_")
26: & numeric value.
27: identifier_str2;
28:
29: /* identifier name starts with underscore */
30: $str3 = <<<_identifier_str3
31: Hello, World
32: hello, world
33: _identifier_str3;
34:
35: /* string containing control characters */
36: $str4 = <<<identifier_str4
37: Hello, World\n
38: Hello\0World
39: identifier_str4;
40:
41: $strings = array(
42: $str1,
43: $str2,
44: $str3,
45: $str4
46: );
47: /* loop through to compare each string with the other string */
48: $count = 1;
49: for($index1 = 0; $index1 < count($strings); $index1++) {
50: var_dump( strncmp( $strings[$index1], $strings[$index1], strlen($strings[$index1]) ) );
51: $count ++;
52: }
53: echo "*** Done ***\n";
54: ?>
55: --EXPECTF--
56: *** Test strncmp() function: with different input strings ***
57: int(0)
58: int(0)
59: int(0)
60: int(0)
61: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>