@@ -93,14 +93,19 @@ foreach ($types as $type) {
93
93
$ loop_count = 1 ;
94
94
foreach ($ values as $ var ) {
95
95
echo "-- Iteration $ loop_count -- \n" ; $ loop_count ++;
96
- // set to new type
97
- var_dump ( settype ($ var , $ type ) );
98
96
99
- // dump the var
100
- var_dump ( $ var );
97
+ try {
98
+ // set to new type
99
+ var_dump ( settype ($ var , $ type ) );
101
100
102
- // check the new type
103
- var_dump ( gettype ($ var ) );
101
+ // dump the var
102
+ var_dump ( $ var );
103
+
104
+ // check the new type
105
+ var_dump ( gettype ($ var ) );
106
+ } catch (ValueError $ exception ) {
107
+ echo $ exception ->getMessage () . "\n" ;
108
+ }
104
109
}
105
110
}
106
111
@@ -539,94 +544,33 @@ string(7) "boolean"
539
544
540
545
-- Setting type of data to resource --
541
546
-- Iteration 1 --
542
- 2: settype(): Cannot convert to resource type
543
- bool(false)
544
- array(3) {
545
- [0]=>
546
- int(1)
547
- [1]=>
548
- int(2)
549
- [2]=>
550
- int(3)
551
- }
552
- string(5) "array"
547
+ Cannot convert to resource type
553
548
-- Iteration 2 --
554
- 2: settype(): Cannot convert to resource type
555
- bool(false)
556
- string(14) "another string"
557
- string(6) "string"
549
+ Cannot convert to resource type
558
550
-- Iteration 3 --
559
- 2: settype(): Cannot convert to resource type
560
- bool(false)
561
- array(3) {
562
- [0]=>
563
- int(2)
564
- [1]=>
565
- int(3)
566
- [2]=>
567
- int(4)
568
- }
569
- string(5) "array"
551
+ Cannot convert to resource type
570
552
-- Iteration 4 --
571
- 2: settype(): Cannot convert to resource type
572
- bool(false)
573
- int(1)
574
- string(7) "integer"
553
+ Cannot convert to resource type
575
554
-- Iteration 5 --
576
- 2: settype(): Cannot convert to resource type
577
- bool(false)
578
- int(-20)
579
- string(7) "integer"
555
+ Cannot convert to resource type
580
556
-- Iteration 6 --
581
- 2: settype(): Cannot convert to resource type
582
- bool(false)
583
- float(2.54)
584
- string(6) "double"
557
+ Cannot convert to resource type
585
558
-- Iteration 7 --
586
- 2: settype(): Cannot convert to resource type
587
- bool(false)
588
- float(-2.54)
589
- string(6) "double"
559
+ Cannot convert to resource type
590
560
-- Iteration 8 --
591
- 2: settype(): Cannot convert to resource type
592
- bool(false)
593
- NULL
594
- string(4) "NULL"
561
+ Cannot convert to resource type
595
562
-- Iteration 9 --
596
- 2: settype(): Cannot convert to resource type
597
- bool(false)
598
- bool(false)
599
- string(7) "boolean"
563
+ Cannot convert to resource type
600
564
-- Iteration 10 --
601
- 2: settype(): Cannot convert to resource type
602
- bool(false)
603
- string(11) "some string"
604
- string(6) "string"
565
+ Cannot convert to resource type
605
566
-- Iteration 11 --
606
- 2: settype(): Cannot convert to resource type
607
- bool(false)
608
- string(6) "string"
609
- string(6) "string"
567
+ Cannot convert to resource type
610
568
-- Iteration 12 --
611
- 2: settype(): Cannot convert to resource type
612
- bool(false)
613
- resource(%d) of type (stream)
614
- string(8) "resource"
569
+ Cannot convert to resource type
615
570
-- Iteration 13 --
616
- 2: settype(): Cannot convert to resource type
617
- bool(false)
618
- resource(%d) of type (stream)
619
- string(8) "resource"
571
+ Cannot convert to resource type
620
572
-- Iteration 14 --
621
- 2: settype(): Cannot convert to resource type
622
- bool(false)
623
- object(point)#1 (2) {
624
- ["x"]=>
625
- int(10)
626
- ["y"]=>
627
- int(20)
628
- }
629
- string(6) "object"
573
+ Cannot convert to resource type
630
574
631
575
-- Setting type of data to array --
632
576
-- Iteration 1 --
0 commit comments