summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/strncmp_error.phpt
blob: ed83651072c0c27909ae5597fdf6bc99fd9cde8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--TEST--
Test strncmp() function : error conditions
--FILE--
<?php
/* Test strncmp() function with more/less number of args and invalid args */

echo "*** Testing strncmp() function: error conditions ***\n";
$str1 = 'string_val';
$str2 = 'string_val';

/* Invalid argument for $len */
$len = -10;

try {
    var_dump( strncmp($str1, $str2, $len) );
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}

?>
--EXPECT--
*** Testing strncmp() function: error conditions ***
strncmp(): Argument #3 ($length) must be greater than or equal to 0