1--TEST--
2Test strncasecmp() function : usage variations - binary safe
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 null terminated strings and binary values passed to 'str1' & 'str2' */
11
12echo "*** Test strncasecmp() function: with null terminated strings and binary inputs ***\n";
13
14/* A binary function should not expect a null terminated string, and it should treat input as a raw stream of data */
15$str1 = "Hello\0world";
16$str2 = "Hello\0";
17$str3 = "Hello,".chr(0)."world";
18var_dump( strncasecmp($str1, $str2, 12) );
19var_dump( strncasecmp($str3, "Hello,world", 12) );
20
21echo "*** Done ***\n";
22?>
23--EXPECTF--
24*** Test strncasecmp() function: with null terminated strings and binary inputs ***
25int(5)
26int(-119)
27*** Done ***
28