2
Test date_offset_get() function : error conditions
6
/* Prototype : int date_offset_get ( DateTime $object )
7
* Description: Returns the daylight saving time offset
8
* Source code: ext/date/php_date.c
9
* Alias to functions: DateTime::getOffset
12
//Set the default time zone
13
date_default_timezone_set("Europe/London");
15
echo "*** Testing date_offset_get() : error conditions ***\n";
17
echo "\n-- Testing date_offset_get() function with zero arguments --\n";
18
var_dump( date_offset_get() );
20
echo "\n-- Testing date_offset_get() function with more than expected no. of arguments --\n";
21
$datetime = date_create("2009-01-30 19:34:10");
23
var_dump( date_offset_get($datetime, $extra_arg) );
25
echo "\n-- Testing date_offset_get() function with an invalid values for \$object argument --\n";
26
$invalid_obj = new stdClass();
27
var_dump( date_offset_get($invalid_obj) );
29
var_dump( date_offset_get($invalid_obj) );
31
var_dump( date_offset_get($invalid_obj) );
35
*** Testing date_offset_get() : error conditions ***
37
-- Testing date_offset_get() function with zero arguments --
39
Warning: date_offset_get() expects exactly 1 parameter, 0 given in %s on line %d
42
-- Testing date_offset_get() function with more than expected no. of arguments --
44
Warning: date_offset_get() expects exactly 1 parameter, 2 given in %s on line %d
47
-- Testing date_offset_get() function with an invalid values for $object argument --
49
Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d
52
Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
55
Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d