This repository has been archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
functions.php
75 lines (66 loc) · 1.82 KB
/
functions.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
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
if (!function_exists('d')) {
/**
* Dump
*
* @param mixed $thing to be dumped
* @param int $i the index in the stack trace to report as here-ish
*/
function d($thing, $i = 0)
{
$trace = debug_backtrace();
$lines = array();
for ($j = $i; $j <= ($i + 1); $j++) {
if (isset($trace[$j]['line'])) {
$lines[] = "Line <b>{$trace[$j]['line']}</b> of <b>{$trace[$j]['file']}</b>";
}
}
if (PHP_SAPI == 'cli') {
echo "\n\033[1;30m==============================\033[0m";
} else {
echo '</script></style><div style="border: 2px solid red; background-color: white; padding: 5px">';
}
$count = 1;
foreach ($lines as $index => $line) {
if ($count > 1) {
$line = " {$line}";
}
if (PHP_SAPI == 'cli') {
echo "\n\033[0;31m{$line}\033[0m";
} else {
if ($count > 1) {
$line = " {$line}";
}
echo "<pre>{$line}</pre>";
}
$count++;
}
if (PHP_SAPI == 'cli') {
echo "\n\033[1;30m==============================\033[0m\n";
}
if (function_exists('ladybug_dump')) {
ladybug_dump($thing);
} else if (extension_loaded('xdebug')) {
var_dump($thing);
} else {
echo '<pre>';
var_dump($thing);
echo '</pre>';
}
if (PHP_SAPI == 'cli') {
echo "\n\n";
} else {
echo '</div><br>';
}
}
/**
* Dump and die.
*
* @param mixed $thing to be dumped
*/
function dd($thing)
{
d($thing, 1);
exit;
}
}