mb_ereg_variation1.phpt [plain text]
--TEST--
Test mb_ereg() function : usage variations - pass different data types to $pattern argument
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build");
?>
--FILE--
<?php
echo "*** Testing mb_ereg() : usage variations ***\n";
$string = 'string value';
$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,
true,
TRUE,
"string",
'string',
$heredoc,
new classA(),
$fp
);
$iterator = 1;
foreach($inputs as $input) {
if (@is_array($regs)){
$regs = null;
}
echo "\n-- Iteration $iterator --\n";
var_dump( mb_ereg($input, $string, $regs) );
var_dump($regs);
$iterator++;
};
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing mb_ereg() : usage variations ***
-- Iteration 1 --
bool(false)
NULL
-- Iteration 2 --
bool(false)
NULL
-- Iteration 3 --
bool(false)
NULL
-- Iteration 4 --
bool(false)
NULL
-- Iteration 5 --
bool(false)
NULL
-- Iteration 6 --
bool(false)
NULL
-- Iteration 7 --
bool(false)
NULL
-- Iteration 8 --
bool(false)
NULL
-- Iteration 9 --
bool(false)
NULL
-- Iteration 10 --
bool(false)
NULL
-- Iteration 11 --
bool(false)
NULL
-- Iteration 12 --
int(6)
array(1) {
[0]=>
string(6) "string"
}
-- Iteration 13 --
int(6)
array(1) {
[0]=>
string(6) "string"
}
-- Iteration 14 --
bool(false)
NULL
-- Iteration 15 --
bool(false)
NULL
-- Iteration 16 --
bool(false)
NULL
Done