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