-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo.php
62 lines (48 loc) · 1.51 KB
/
demo.php
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php /**
* Demonstration of what Wano does
*/
if (!class_exists('\\Wano\\Nab'))
{
require __DIR__ . '/../autoload.php';
}
/* enable Wano to start collecting PHP error messages */
\Wano\Nab::register();
/* make it collect backtraces only for warnings */
\Wano\Nab::$backtrace = E_WARNING | E_USER_WARNING;
/* Now let's do some stuff that raise PHP error messages */
/* Will trigger PHP notice "Undefined variable: y" */
$x[$y]['b'][] = 123;
/* Will trigger PHP notice "Undefined variable: a" */
$z = $x[$a];
/* Will trigger PHP notice "Array to string conversion" */
$stuff = array(1,2,3);
(string) $stuff;
/* Let's nest some functions so that we get a nice backtrace */
function a123()
{
/* Will trigger PHP warning "proba" */
trigger_error('proba', E_USER_WARNING);
/* Will trigger PHP warning "Invalid error type specified" */
trigger_error('test', E_WARNING);
}
function b456()
{
a123();
}
b456();
/* Will trigger xxxx */
/* Will trigger:
- PHP notice "Undefined variable: c"
- PHP warning "Invalid argument supplied for foreach()"
*/
foreach ($c as $i) {}
/* Will trigger 5 times each:
- PHP notice "Undefined variable: b"
- PHP warning "fopen() expects at least 2 parameters, 1 given"
*/
for ($i=0; $i<5; $i++) fopen($b);
/* Will trigger PHP strict "Non-static method x::c() should not be called statically" */
class x { function c() {}}
x::c();
/* Will trigger PHP deprecated "mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead" */
mysql_connect();