File tree Expand file tree Collapse file tree 9 files changed +19
-19
lines changed Expand file tree Collapse file tree 9 files changed +19
-19
lines changed Original file line number Diff line number Diff line change 7
7
$ divisor = 0 ;
8
8
$ result = 1 / $ divisor ;
9
9
var_dump ($ result );
10
- } catch (Throwable $ t ){
10
+ } catch (DivisionByZeroError $ t ){
11
11
echo "Variable div \n" ;
12
12
printf ("Type: %s \n" , get_class ($ t ));
13
13
printf ("Message: %s \n" , $ t ->getMessage ());
17
17
$ divisor = 0 ;
18
18
$ result = 1 % $ divisor ;
19
19
var_dump ($ result );
20
- } catch (Throwable $ t ){
20
+ } catch (DivisionByZeroError $ t ){
21
21
echo "\nVariable mod \n" ;
22
22
printf ("Type: %s \n" , get_class ($ t ));
23
23
printf ("Message: %s \n" , $ t ->getMessage ());
26
26
try {
27
27
$ result = 1 / 0 ;
28
28
var_dump ($ result );
29
- } catch (Throwable $ t ){
29
+ } catch (DivisionByZeroError $ t ){
30
30
echo "\nLiteral div \n" ;
31
31
printf ("Type: %s \n" , get_class ($ t ));
32
32
printf ("Message: %s \n" , $ t ->getMessage ());
35
35
try {
36
36
$ result = 1 % 0 ;
37
37
var_dump ($ result );
38
- } catch (Throwable $ t ){
38
+ } catch (DivisionByZeroError $ t ){
39
39
echo "\nLiteral mod \n" ;
40
40
printf ("Type: %s \n" , get_class ($ t ));
41
41
printf ("Message: %s \n" , $ t ->getMessage ());
44
44
try {
45
45
$ result = 1 / 0.0 ;
46
46
var_dump ($ result );
47
- } catch (Throwable $ t ){
47
+ } catch (DivisionByZeroError $ t ){
48
48
echo "\nDouble div \n" ;
49
49
printf ("Type: %s \n" , get_class ($ t ));
50
50
printf ("Message: %s \n" , $ t ->getMessage ());
53
53
try {
54
54
$ result = 1 % 0.0 ;
55
55
var_dump ($ result );
56
- } catch (Throwable $ t ){
56
+ } catch (DivisionByZeroError $ t ){
57
57
echo "\nDouble mod \n" ;
58
58
printf ("Type: %s \n" , get_class ($ t ));
59
59
printf ("Message: %s \n" , $ t ->getMessage ());
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ $n = "-1";
11
11
try {
12
12
$ n <<= $ n ;
13
13
var_dump ($ n );
14
- } catch (Throwable $ e ) {
14
+ } catch (ArithmeticError $ e ) {
15
15
echo "\nException: " . $ e ->getMessage () . "\n" ;
16
16
}
17
17
@@ -23,15 +23,15 @@ $n = "-1";
23
23
try {
24
24
$ n >>= $ n ;
25
25
var_dump ($ n );
26
- } catch (Throwable $ e ) {
26
+ } catch (ArithmeticError $ e ) {
27
27
echo "\nException: " . $ e ->getMessage () . "\n" ;
28
28
}
29
29
30
30
$ n = "0 " ;
31
31
try {
32
32
$ n %= $ n ;
33
33
var_dump ($ n );
34
- } catch (Throwable $ e ) {
34
+ } catch (DivisionByZeroError $ e ) {
35
35
echo "\nException: " . $ e ->getMessage () . "\n" ;
36
36
}
37
37
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ $b = array();
9
9
try {
10
10
$ c = $ a % $ b ;
11
11
var_dump ($ c );
12
- } catch (Throwable $ e ) {
12
+ } catch (DivisionByZeroError $ e ) {
13
13
echo "Exception: " . $ e ->getMessage () . "\n" ;
14
14
}
15
15
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ foreach ($longVals as $longVal) {
27
27
echo "--- testing: $ longVal << $ otherVal --- \n" ;
28
28
try {
29
29
var_dump ($ longVal <<$ otherVal );
30
- } catch (Throwable $ e ) {
30
+ } catch (ArithmeticError $ e ) {
31
31
echo "Exception: " . $ e ->getMessage () . "\n" ;
32
32
}
33
33
}
@@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) {
38
38
echo "--- testing: $ otherVal << $ longVal --- \n" ;
39
39
try {
40
40
var_dump ($ otherVal <<$ longVal );
41
- } catch (Throwable $ e ) {
41
+ } catch (ArithmeticError $ e ) {
42
42
echo "Exception: " . $ e ->getMessage () . "\n" ;
43
43
}
44
44
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ foreach ($strVals as $strVal) {
19
19
echo "--- testing: ' $ strVal' << ' $ otherVal' --- \n" ;
20
20
try {
21
21
var_dump ($ strVal <<$ otherVal );
22
- } catch (Throwable $ e ) {
22
+ } catch (ArithmeticError $ e ) {
23
23
echo "Exception: " . $ e ->getMessage () . "\n" ;
24
24
}
25
25
}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ foreach ($longVals as $longVal) {
27
27
echo "--- testing: $ longVal >> $ otherVal --- \n" ;
28
28
try {
29
29
var_dump ($ longVal >>$ otherVal );
30
- } catch (Throwable $ e ) {
30
+ } catch (ArithmeticError $ e ) {
31
31
echo "Exception: " . $ e ->getMessage () . "\n" ;
32
32
}
33
33
}
@@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) {
38
38
echo "--- testing: $ otherVal >> $ longVal --- \n" ;
39
39
try {
40
40
var_dump ($ otherVal >>$ longVal );
41
- } catch (Throwable $ e ) {
41
+ } catch (ArithmeticError $ e ) {
42
42
echo "Exception: " . $ e ->getMessage () . "\n" ;
43
43
}
44
44
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ foreach ($strVals as $strVal) {
15
15
echo "--- testing: ' $ strVal' >> ' $ otherVal' --- \n" ;
16
16
try {
17
17
var_dump ($ strVal >>$ otherVal );
18
- } catch (Throwable $ e ) {
18
+ } catch (ArithmeticError $ e ) {
19
19
echo "Exception: " . $ e ->getMessage () . "\n" ;
20
20
}
21
21
}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ foreach ($longVals as $longVal) {
27
27
echo "--- testing: $ longVal % $ otherVal --- \n" ;
28
28
try {
29
29
var_dump ($ longVal %$ otherVal );
30
- } catch (Throwable $ e ) {
30
+ } catch (DivisionByZeroError $ e ) {
31
31
echo "Exception: " . $ e ->getMessage () . "\n" ;
32
32
}
33
33
}
@@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) {
38
38
echo "--- testing: $ otherVal % $ longVal --- \n" ;
39
39
try {
40
40
var_dump ($ otherVal %$ longVal );
41
- } catch (Throwable $ e ) {
41
+ } catch (DivisionByZeroError $ e ) {
42
42
echo "Exception: " . $ e ->getMessage () . "\n" ;
43
43
}
44
44
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ foreach ($strVals as $strVal) {
15
15
echo "--- testing: ' $ strVal' % ' $ otherVal' --- \n" ;
16
16
try {
17
17
var_dump ($ strVal %$ otherVal );
18
- } catch (Throwable $ e ) {
18
+ } catch (DivisionByZeroError $ e ) {
19
19
echo "Exception: " . $ e ->getMessage () . "\n" ;
20
20
}
21
21
}
You can’t perform that action at this time.
0 commit comments