Annotation of embedaddon/php/ext/pcre/tests/preg_match_error2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test preg_match() function : error conditions - wrong arg types
! 3: --FILE--
! 4: <?php
! 5: /*
! 6: * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
! 7: * Function is implemented in ext/pcre/php_pcre.c
! 8: */
! 9: error_reporting(E_ALL&~E_NOTICE);
! 10: /*
! 11: * Testing how preg_match reacts to being passed the wrong type of subject argument
! 12: */
! 13: echo "*** Testing preg_match() : error conditions ***\n";
! 14: $regex = '/[a-zA-Z]/';
! 15: $input = array('this is a string', array('this is', 'a subarray'),);
! 16: foreach($input as $value) {
! 17: print "\nArg value is: $value\n";
! 18: var_dump(preg_match($regex, $value));
! 19: }
! 20: $value = new stdclass(); //Object
! 21: var_dump(preg_match($regex, $value));
! 22: echo "Done";
! 23: ?>
! 24: --EXPECTF--
! 25:
! 26: *** Testing preg_match() : error conditions ***
! 27:
! 28: Arg value is: this is a string
! 29: int(1)
! 30:
! 31: Arg value is: Array
! 32:
! 33: Warning: preg_match() expects parameter 2 to be string, array given in %spreg_match_error2.php on line %d
! 34: bool(false)
! 35:
! 36: Warning: preg_match() expects parameter 2 to be string, object given in %spreg_match_error2.php on line %d
! 37: bool(false)
! 38: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>