1
0
mirror of https://github.com/php/php-src.git synced 2026-03-29 19:52:20 +02:00
Files
archived-php-src/ext/standard/tests/array/extract_error.phpt
George Peter Banyard 5fbd49f9ab Convert Errors to ValueErrors
Closes GH-4930
2019-12-05 14:22:54 +01:00

39 lines
857 B
PHP

--TEST--
Test extract() function (error conditions)
--FILE--
<?php
/* Testing Error Conditions */
echo "*** Testing Error Conditions ***\n";
/* Invalid second argument ( only 0-6 is valid) */
$arr = array(1);
try {
var_dump( extract($arr, -1 . "wddr") );
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump( extract($arr, 7 , "wddr") );
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
/* Two Arguments, second as prefix but without prefix string as third argument */
try {
var_dump( extract($arr,EXTR_PREFIX_IF_EXISTS) );
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
*** Testing Error Conditions ***
Notice: A non well formed numeric value encountered in %s on line %d
Invalid extract type
Invalid extract type
Specified extract type requires the prefix parameter