Annotation of embedaddon/php/ext/standard/tests/strings/strncasecmp_variation9.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strncasecmp() function: usage variations - heredoc strings
3: --FILE--
4: <?php
5: /* Prototype : int strncasecmp ( string $str1, string $str2, int $len );
6: * Description: Binary safe case-insensitive string comparison of the first n characters
7: * Source code: Zend/zend_builtin_functions.c
8: */
9:
10: /* Test strncasecmp() function with here-doc strings for 'str1', 'str2' */
11:
12: echo "*** Test strncasecmp() function: with here-doc strings ***\n";
13:
14: /* multi line heredoc string */
15: $multi_line_str = <<<EOD
16: Example of string
17: spanning multiple lines
18: using heredoc syntax.
19: EOD;
20:
21: /* identifier name contains underscore */
22: $identifier_str1 = <<<identifier_str1
23: Example of heredoc
24: string, whose identifier
25: having underscore("_")
26: & numeric value.
27: identifier_str1;
28:
29: /* identifier name starts with underscore */
30: $identifier_str2 = <<<_identifier_str2
31: Hello, World
32: hello, world
33: _identifier_str2;
34:
35: /* string containing control character */
36: $control_char_str = <<<EOD
37: Hello, World\n
38: Hello\0World
39: EOD;
40:
41: /* heredoc string with quote chars & slash */
42: $quote_char_string = <<<EOD
43: it's bright,but i cann't see it.
44: "things in double quote"
45: 'things in single quote'
46: this\line is /with\slashs
47: EOD;
48:
49: /* heredoc string with blank line */
50: $blank_line = <<<EOD
51:
52: EOD;
53:
54: /* empty heredoc string */
55: $empty_string = <<<EOD
56: EOD;
57:
58: $strings = array(
59: $multi_line_str,
60: $identifier_str1,
61: $identifier_str2,
62: $control_char_str,
63: $quote_char_string,
64: $blank_line,
65: $empty_string
66: );
67: /* loop through to compare the strings */
68: $index2 = count($strings);
69: for($index1 = 0; $index1 < count($strings); $index1++) {
70: $index2--;
71: var_dump( strncasecmp( $strings[$index1], $strings[$index1], strlen($strings[$index1]) ) );
72: var_dump( strncasecmp( $strings[$index1], $strings[$index2], strlen($strings[$index1]) ) );
73: }
74: echo "*** Done ***\n";
75: ?>
76: --EXPECTF--
77: *** Test strncasecmp() function: with here-doc strings ***
78: int(0)
79: int(63)
80: int(0)
81: int(84)
82: int(0)
83: int(-1)
84: int(0)
85: int(0)
86: int(0)
87: int(1)
88: int(0)
89: int(0)
90: int(0)
91: int(0)
92: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>