preg_grep_error1.phpt [plain text]
--TEST--
Test preg_grep() function : error conditions - bad regular expressions
--FILE--
<?php
error_reporting(E_ALL&~E_NOTICE);
echo "*** Testing preg_grep() : error conditions ***\n";
$values = array('abcdef', '/[a-zA-Z]', '[a-zA-Z]/', '/[a-zA-Z]/F', array('[a-z]', '[A-Z]', '[0-9]'), '/[a-zA-Z]/', );
$array = array(123, 'abc', 'test');
foreach($values as $value) {
print "\nArg value is $value\n";
var_dump(preg_grep($value, $array));
}
$value = new stdclass(); var_dump(preg_grep($value, $array));
echo "Done"
?>
--EXPECTF--
*** Testing preg_grep() : error conditions ***
Arg value is abcdef
Warning: preg_grep(): Delimiter must not be alphanumeric or backslash in %spreg_grep_error1.php on line %d
bool(false)
Arg value is /[a-zA-Z]
Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d
bool(false)
Arg value is [a-zA-Z]/
Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d
bool(false)
Arg value is /[a-zA-Z]/F
Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d
bool(false)
Arg value is Array
Warning: preg_grep() expects parameter 1 to be string, array given in %spreg_grep_error1.php on line %d
NULL
Arg value is /[a-zA-Z]/
array(2) {
[1]=>
string(3) "abc"
[2]=>
string(4) "test"
}
Warning: preg_grep() expects parameter 1 to be string, object given in %spreg_grep_error1.php on line %d
NULL
Done