-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.php
More file actions
46 lines (36 loc) · 983 Bytes
/
demo.php
File metadata and controls
46 lines (36 loc) · 983 Bytes
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
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Calvert\DndErrors\DndErrors;
DndErrors::boot(array(
'archetype' => 'random', // Randomly picks between available archetypes
));
// Use Unix timestamp to cycle through different error types
$errorType = time() % 6;
switch ($errorType) {
case 0:
// Undefined variable
echo $undefinedVariable;
break;
case 1:
// Null pointer / count() on null (deprecated warning in PHP 8.1+)
$array = null;
count($array);
break;
case 2:
// Call to undefined function
undefinedFunctionCall();
break;
case 3:
// Type error / wrong argument count
substr('hello', 0, 5, 10); // substr doesn't accept 4 arguments
break;
case 4:
// Array offset on null
$data = null;
$data['key'] = 'value';
break;
case 5:
// Division by zero
$result = 10 / 0;
break;
}