mb_stripos_variation2.phpt [plain text]
--TEST--
Test mb_stripos() function : usage variations - pass different data types as $needle arg
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_stripos') or die("skip mb_stripos() is not available in this build");
?>
--FILE--
<?php
echo "*** Testing mb_stripos() : usage variations ***\n";
$haystack = b'string_val';
$offset = 0;
$encoding = 'utf-8';
$unset_var = 10;
unset ($unset_var);
class classA
{
public function __toString() {
return "Class A object";
}
}
$heredoc = <<<EOT
hello world
EOT;
$fp = fopen(__FILE__, "r");
$inputs = array(
0,
1,
12345,
-2345,
10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
NULL,
null,
true,
false,
TRUE,
FALSE,
"",
'',
b"string",
b'string',
$heredoc,
new classA(),
@$undefined_var,
@$unset_var,
$fp
);
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( mb_stripos($haystack, $input, $offset, $encoding));
$iterator++;
};
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing mb_stripos() : usage variations ***
-- Iteration 1 --
bool(false)
-- Iteration 2 --
bool(false)
-- Iteration 3 --
bool(false)
-- Iteration 4 --
bool(false)
-- Iteration 5 --
bool(false)
-- Iteration 6 --
bool(false)
-- Iteration 7 --
bool(false)
-- Iteration 8 --
bool(false)
-- Iteration 9 --
bool(false)
-- Iteration 10 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 11 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 12 --
bool(false)
-- Iteration 13 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 14 --
bool(false)
-- Iteration 15 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 16 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 17 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 18 --
int(0)
-- Iteration 19 --
int(0)
-- Iteration 20 --
bool(false)
-- Iteration 21 --
bool(false)
-- Iteration 22 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 23 --
Warning: mb_stripos(): Empty delimiter in %s on line %d
bool(false)
-- Iteration 24 --
Warning: mb_stripos() expects parameter 2 to be string, resource given in %s on line %d
NULL
Done