1--TEST--
2Test gettype() & settype() functions : error conditions
3--FILE--
4<?php
5/* Prototype: string gettype ( mixed $var );
6   Description: Returns the type of the PHP variable var
7
8   Prototype: bool settype ( mixed &$var, string $type );
9   Description: Set the type of variable var to type
10*/
11
12/* Test different error conditions of settype() and gettype() functions */
13
14echo "**** Testing gettype() and settype() functions ****\n";
15
16echo "\n*** Testing gettype(): error conditions ***\n";
17//Zero arguments
18var_dump( gettype() );
19// args more than expected
20var_dump( gettype( "1", "2" ) );
21
22echo "\n*** Testing settype(): error conditions ***\n";
23//Zero arguments
24var_dump( settype() );
25
26// args more than expected
27$var = 10.5;
28var_dump( settype( $var, $var, "int" ) );
29
30// passing an invalid type to set
31var_dump( settype( $var, "unknown" ) );
32
33echo "Done\n";
34?>
35--EXPECTF--
36**** Testing gettype() and settype() functions ****
37
38*** Testing gettype(): error conditions ***
39
40Warning: gettype() expects exactly 1 parameter, 0 given in %s on line %d
41NULL
42
43Warning: gettype() expects exactly 1 parameter, 2 given in %s on line %d
44NULL
45
46*** Testing settype(): error conditions ***
47
48Warning: settype() expects exactly 2 parameters, 0 given in %s on line %d
49NULL
50
51Warning: settype() expects exactly 2 parameters, 3 given in %s on line %d
52NULL
53
54Warning: settype(): Invalid type in %s on line %d
55bool(false)
56Done
57