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