Return to gettype_settype_error.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / general_functions |
1.1 misho 1: --TEST-- 2: Test 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: 14: echo "**** Testing gettype() and settype() functions ****\n"; 15: 16: echo "\n*** Testing gettype(): error conditions ***\n"; 17: //Zero arguments 18: var_dump( gettype() ); 19: // args more than expected 20: var_dump( gettype( "1", "2" ) ); 21: 22: echo "\n*** Testing settype(): error conditions ***\n"; 23: //Zero arguments 24: var_dump( settype() ); 25: 26: // args more than expected 27: $var = 10.5; 28: var_dump( settype( $var, $var, "int" ) ); 29: 30: // passing an invalid type to set 31: var_dump( settype( $var, "unknown" ) ); 32: 33: echo "Done\n"; 34: ?> 35: --EXPECTF-- 36: **** Testing gettype() and settype() functions **** 37: 38: *** Testing gettype(): error conditions *** 39: 40: Warning: gettype() expects exactly 1 parameter, 0 given in %s on line %d 41: NULL 42: 43: Warning: gettype() expects exactly 1 parameter, 2 given in %s on line %d 44: NULL 45: 46: *** Testing settype(): error conditions *** 47: 48: Warning: settype() expects exactly 2 parameters, 0 given in %s on line %d 49: NULL 50: 51: Warning: settype() expects exactly 2 parameters, 3 given in %s on line %d 52: NULL 53: 54: Warning: settype(): Invalid type in %s on line %d 55: bool(false) 56: Done