mb_strrpos_variation3.phpt [plain text]
--TEST--
Test mb_strrpos() function : usage variations - Pass different data types as $offset arg
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_strrpos') or die("skip mb_strrpos() is not available in this build");
?>
--FILE--
<?php
echo "*** Testing mb_strrpos() : usage variations ***\n";
$needle = b'a';
$haystack = b'string_val';
$encoding = 'utf-8';
$unset_var = 10;
unset ($unset_var);
class classA
{
public function __toString() {
return b"7";
}
}
$heredoc = b<<<EOT
hello world
EOT;
$inputs = array(
0,
1,
12345,
-2345,
10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
NULL,
null,
true,
false,
TRUE,
FALSE,
new classA(),
@$undefined_var,
@$unset_var
);
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( mb_strrpos($haystack, $needle, $input, $encoding));
$iterator++;
};
echo "Done";
?>
--EXPECTF--
*** Testing mb_strrpos() : usage variations ***
-- Iteration 1 --
int(8)
-- Iteration 2 --
int(8)
-- Iteration 3 --
Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
-- Iteration 4 --
Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
-- Iteration 5 --
bool(false)
-- Iteration 6 --
bool(false)
-- Iteration 7 --
Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
-- Iteration 8 --
int(8)
-- Iteration 9 --
int(8)
-- Iteration 10 --
int(8)
-- Iteration 11 --
int(8)
-- Iteration 12 --
int(8)
-- Iteration 13 --
int(8)
-- Iteration 14 --
int(8)
-- Iteration 15 --
int(8)
-- Iteration 16 --
Notice: Object of class classA could not be converted to int in %s on line %d
int(8)
-- Iteration 17 --
int(8)
-- Iteration 18 --
int(8)
Done