-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
97 lines (82 loc) · 2.65 KB
/
index.php
File metadata and controls
97 lines (82 loc) · 2.65 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
function highlight($data, $tab = 1)
{
$indent = str_repeat(' ', $tab);
$closingIndent = str_repeat(' ', max(0, $tab - 1));
if (is_array($data)) {
$output = [];
foreach ($data as $key => $value) {
$keyFormatted = "\"<span class='sf-dump-str'>$key</span>\"";
$valueFormatted = highlight($value, $tab + 2);
$output[] = "$indent$keyFormatted => $valueFormatted";
}
$content = implode(",\n", $output);
$count = count($output);
return "<span class='sf-dump-note'>array:$count</span> [\n$content\n$closingIndent]";
} elseif (is_object($data)) {
$output = [];
foreach (get_object_vars($data) as $key => $value) {
$keyFormatted = "\"<span class='sf-dump-str'>$key</span>\"";
$valueFormatted = highlight($value, $tab + 2);
$output[] = "$indent$keyFormatted => $valueFormatted";
}
$content = implode(",\n", $output);
$className = get_class($data);
return "<span class='sf-dump-note'>$className</span> {\n$content\n$closingIndent}";
} elseif (is_string($data)) {
return "\"<span class='sf-dump-str'>$data</span>\"";
} elseif (is_int($data) || is_float($data)) {
return "<span class='sf-dump-num'>$data</span>";
} elseif (is_bool($data)) {
return "<span class='sf-dump-const'>" . ($data ? 'true' : 'false') . "</span>";
} elseif (is_null($data)) {
return "<span class='sf-dump-const'>null</span>";
}
return $data;
}
function dump($data)
{
echo "<style>
.sf-dump {
background: #18171B;
color: #FF8400;
font: 12px 'JetBrains Mono', Menlo, Monaco, Consolas, monospace;
word-wrap: break-word;
white-space: pre-wrap;
position: relative;
z-index: 99999;
word-break: break-word;
padding: .4rem;
margin-bottom: 0.1rem;
overflow: auto;
max-height: 400px;
}
pre.sf-dump .sf-dump-key {
color: #FF8400;
font-weight: bold;
}
pre.sf-dump .sf-dump-str {
color: #56DB3A;
}
pre.sf-dump .sf-dump-num {
color: #1299DA;
}
pre.sf-dump .sf-dump-const {
font-weight: bold;
}
pre.sf-dump .sf-dump-note {
color: #1299DA;
}
pre.sf-dump .sf-dump-public {
color: #FFFFFF;
}
</style>";
echo "<pre class='sf-dump'>";
echo highlight($data);
echo "</pre>";
}
function dd($data)
{
dump($data);
die();
}