2
Test strncasecmp() function : usage variations - unexpected values for 'str1'
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
10
/* Test strncasecmp() function with the unexpected inputs for 'str1' */
12
echo "*** Testing strncasecmp() function: with unexpected values for 'str1' ***\n";
13
/* get an unset variable */
14
$unset_var = 'string_val';
17
/* get resource handle */
18
$file_handle = fopen(__FILE__, "r");
20
/* declaring a class */
22
public function __toString() {
28
/* array with different values */
43
/* hexadecimal values */
57
array('color' => 'red', 'item' => 'pen'),
73
/* undefined variable */
86
/* loop through each element of the array and check the working of strncasecmp() */
88
for($index = 0; $index < count($values); $index ++) {
89
echo "-- Iteration $counter --\n";
90
$str1 = $values[$index];
91
$len = strlen($values[$index]) + 1;
92
var_dump( strncasecmp($str1, "string", $len) );
96
fclose($file_handle); //closing the file handle
98
echo "*** Done ***\n";
101
*** Testing strncasecmp() function: with unexpected values for 'str1' ***
132
Warning: strlen() expects parameter 1 to be string, array given in %s on line 88
134
Warning: strncasecmp() expects parameter 1 to be string, array given in %s on line 89
138
Warning: strlen() expects parameter 1 to be string, array given in %s on line 88
140
Warning: strncasecmp() expects parameter 1 to be string, array given in %s on line 89
144
Warning: strlen() expects parameter 1 to be string, array given in %s on line 88
146
Warning: strncasecmp() expects parameter 1 to be string, array given in %s on line 89
150
Warning: strlen() expects parameter 1 to be string, array given in %s on line 88
152
Warning: strncasecmp() expects parameter 1 to be string, array given in %s on line 89
156
Warning: strlen() expects parameter 1 to be string, array given in %s on line 88
158
Warning: strncasecmp() expects parameter 1 to be string, array given in %s on line 89
182
Warning: strlen() expects parameter 1 to be string, resource given in %s on line 88
184
Warning: strncasecmp() expects parameter 1 to be string, resource given in %s on line 89