1--TEST--
2Test strval() function : usage variations  - error conditions
3--FILE--
4<?php
5/* Prototype  : string strval  ( mixed $var  )
6 * Description: Get the string value of a variable.
7 * Source code: ext/standard/string.c
8 */
9
10echo "*** Testing strval() : error conditions ***\n";
11
12error_reporting(E_ALL ^ E_NOTICE);
13
14class MyClass
15{
16	// no toString() method defined
17}
18
19$string  = "Hello";
20$extra_arg = 10;
21
22//Test strval with one more than the expected number of arguments
23echo "\n-- Testing strval() function with more than expected no. of arguments --\n";
24var_dump( strval($string, $extra_arg) );
25
26// Testing strval with one less than the expected number of arguments
27echo "\n-- Testing strval() function with less than expected no. of arguments --\n";
28var_dump( strval() );
29
30// Testing strval with a object which has no toString() method
31echo "\n-- Testing strval() function with object which has not toString() method  --\n";
32var_dump( strval(new MyClass()) );
33
34?>
35===DONE===
36--EXPECTF--
37*** Testing strval() : error conditions ***
38
39-- Testing strval() function with more than expected no. of arguments --
40
41Warning: strval() expects exactly 1 parameter, 2 given in %s on line %d
42NULL
43
44-- Testing strval() function with less than expected no. of arguments --
45
46Warning: strval() expects exactly 1 parameter, 0 given in %s on line %d
47NULL
48
49-- Testing strval() function with object which has not toString() method  --
50
51Catchable fatal error: Object of class MyClass could not be converted to string in %s on line %d