-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.php
49 lines (43 loc) · 1.01 KB
/
helpers.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
<?php
function view($file,$vars = []) {
$file = "app.Views.".$file;
$file = str_replace('.', '/', $file);
$file = rtrim($file,'.php').'.php';
if(!empty($vars)){
extract($vars);
}
include_once($file);
}
function config($var = false) {
foreach (glob("config/*.php") as $filename) {
$path = dirname(__FILE__) . '/' . $filename;
if (is_file($path)) {
$config[rtrim(basename($filename),'.php')] = (require $path);
}
}
if($var){
foreach(explode('.', $var) as $arr){
$config = $config[$arr];
}
return $config;
}
return $config;
}
function pd($data , $die = true){
echo "<pre>";
print_r($data);
echo "</pre>";
if ($die) die();
}
function console($value, $return = false){
static $count = 0;
$string = json_encode(print_r($value, true));
if (!$return)
{
$count++;
echo("<script>console.log('Output $count:');</script>");
echo("<script>console.log($string);</script>");
}
else
return $string;
}