1--TEST--
2Test strncmp() function: usage variations - single quoted 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 single quoted strings for 'str1', 'str2' */
11
12echo "*** Test strncmp() function: with single quoted strings ***\n";
13$strings = array(
14  'Hello, World',
15  'hello, world',
16  'HELLO, WORLD',
17  'Hello, World\n'
18);
19/* loop through to compare each string with the other string */
20$count = 1;
21for($index1 = 0; $index1 < count($strings); $index1++) {
22  echo "-- Iteration $count --\n";
23  for($index2 = 0; $index2 < count($strings); $index2++) {
24    var_dump( strncmp( $strings[$index1], $strings[$index2], (strlen($strings[$index1]) + 1) ) );
25  }
26  $count ++;
27}
28echo "*** Done ***\n";
29?>
30--EXPECTREGEX--
31\*\*\* Test strncmp\(\) function: with single quoted strings \*\*\*
32-- Iteration 1 --
33int\(0\)
34int\(-[1-9][0-9]*\)
35int\([1-9][0-9]*\)
36int\(-[1-9][0-9]*\)
37-- Iteration 2 --
38int\([1-9][0-9]*\)
39int\(0\)
40int\([1-9][0-9]*\)
41int\([1-9][0-9]*\)
42-- Iteration 3 --
43int\(-[1-9][0-9]*\)
44int\(-[1-9][0-9]*\)
45int\(0\)
46int\(-[1-9][0-9]*\)
47-- Iteration 4 --
48int\([1-9][0-9]*\)
49int\(-[1-9][0-9]*\)
50int\([1-9][0-9]*\)
51int\(0\)
52\*\*\* Done \*\*\*
53