extract_error.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. Test extract() function (error conditions)
  3. --FILE--
  4. <?php
  5. /* Testing Error Conditions */
  6. echo "*** Testing Error Conditions ***\n";
  7. /* Zero Arguments */
  8. var_dump( extract() );
  9. /* Invalid second argument ( only 0-6 is valid) */
  10. $arr = array(1);
  11. var_dump( extract($arr, -1 . "wddr") );
  12. var_dump( extract($arr, 7 , "wddr") );
  13. /* scalar argument */
  14. $val = 1;
  15. var_dump( extract($val) );
  16. /* string argument */
  17. $str = "test";
  18. var_dump( extract($str) );
  19. /* More than valid number of arguments i.e. 3 args */
  20. var_dump( extract($arr, EXTR_SKIP, "aa", "ee") );
  21. /* Two Arguments, second as prefix but without prefix string as third argument */
  22. var_dump( extract($arr,EXTR_PREFIX_IF_EXISTS) );
  23. echo "Done\n";
  24. ?>
  25. --EXPECTF--
  26. *** Testing Error Conditions ***
  27. Warning: extract() expects at least 1 parameter, 0 given in %s on line %d
  28. NULL
  29. Notice: A non well formed numeric value encountered in %s on line %d
  30. Warning: extract(): Invalid extract type in %s on line %d
  31. NULL
  32. Warning: extract(): Invalid extract type in %s on line %d
  33. NULL
  34. Warning: extract() expects parameter 1 to be array, integer given in %s on line %d
  35. NULL
  36. Warning: extract() expects parameter 1 to be array, string given in %s on line %d
  37. NULL
  38. Warning: extract() expects at most 3 parameters, 4 given in %s on line %d
  39. NULL
  40. Warning: extract(): specified extract type requires the prefix parameter in %s on line %d
  41. NULL
  42. Done