1--TEST--
2Test 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
12echo "*** Test strncmp() function: with different input strings ***\n";
13
14/* heredoc string */
15$str1 = <<<EOD
16Example of string
17spanning multiple lines
18using heredoc syntax.
19EOD;
20
21/* identifier name contains underscore */
22$str2 = <<<identifier_str2
23Example of heredoc
24string, whose identifier
25having underscore("_")
26& numeric value.
27identifier_str2;
28
29/* identifier name starts with underscore */
30$str3 = <<<_identifier_str3
31Hello, World
32hello, world
33_identifier_str3;
34
35/* string containing control characters */
36$str4 = <<<identifier_str4
37Hello, World\n
38Hello\0World
39identifier_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;
49for($index1 = 0; $index1 < count($strings); $index1++) {
50  var_dump( strncmp( $strings[$index1], $strings[$index1], strlen($strings[$index1]) ) );
51  $count ++;
52}
53echo "*** Done ***\n";
54?>
55--EXPECT--
56*** Test strncmp() function: with different input strings ***
57int(0)
58int(0)
59int(0)
60int(0)
61*** Done ***
62