preg_quote_error1.phpt 1005 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Test preg_quote() function : error conditions - wrong arg types
  3. --FILE--
  4. <?php
  5. /*
  6. * proto string preg_quote(string str [, string delim_char])
  7. * Function is implemented in ext/pcre/php_pcre.c
  8. */
  9. error_reporting(E_ALL&~E_NOTICE);
  10. /*
  11. * Testing how preg_quote reacts to being passed the wrong type of input argument
  12. */
  13. echo "*** Testing preg_quote() : error conditions ***\n";
  14. $input = array('this is a string', array('this is', 'a subarray'),);
  15. foreach($input as $value) {
  16. print "\nArg value is: $value\n";
  17. var_dump(preg_quote($value));
  18. }
  19. $value = new stdclass(); //Object
  20. var_dump(preg_quote($value));
  21. echo "Done";
  22. ?>
  23. --EXPECTF--
  24. *** Testing preg_quote() : error conditions ***
  25. Arg value is: this is a string
  26. string(16) "this is a string"
  27. Arg value is: Array
  28. Warning: preg_quote() expects parameter 1 to be string, array given in %spreg_quote_error1.php on line %d
  29. NULL
  30. Warning: preg_quote() expects parameter 1 to be string, object given in %spreg_quote_error1.php on line %d
  31. NULL
  32. Done