Skip to content

Commit b3bf401

Browse files
authored
公共文件
包括配置文件和公共函数文件
1 parent 64b3b47 commit b3bf401

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Common/bootstrop.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
4+
defined('SEC_ROOT_PATH') or define('SEC_ROOT_PATH',dirname(dirname(__FILE__)));
5+
defined('DOMAIN_NAME') or define('DOMAIN_NAME',$_SERVER['SERVER_NAME']);
6+
7+
include 'function.php';
8+
include 'app/common.php';
9+
include 'Model/Model.php';
10+
include 'Model/OrderModel.php';
11+
include 'Model/GoodsModel.php';
12+
include 'Redis/QRedis.php';

Common/function.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
3+
<?php
4+
5+
6+
/*------------------------
7+
* 公共函数
8+
* @author zsx
9+
* @date 2016-02-09
10+
*------------------------
11+
*/
12+
13+
14+
/**
15+
* 浏览器友好的变量输出
16+
* @param mixed $var 变量
17+
* @param boolean $echo 是否输出 默认为True 如果为false 则返回输出字符串
18+
* @param string $label 标签 默认为空
19+
* @param boolean $strict 是否严谨 默认为true
20+
* @return void|string
21+
*/
22+
function dump($var, $echo=true, $label=null, $strict=true) {
23+
$label = ($label === null) ? '' : rtrim($label) . ' ';
24+
if (!$strict) {
25+
if (ini_get('html_errors')) {
26+
$output = print_r($var, true);
27+
$output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
28+
} else {
29+
$output = $label . print_r($var, true);
30+
}
31+
} else {
32+
ob_start();
33+
var_dump($var);
34+
$output = ob_get_clean();
35+
if (!extension_loaded('xdebug')) {
36+
$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
37+
$output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
38+
}
39+
}
40+
if ($echo) {
41+
echo($output);
42+
return null;
43+
}else
44+
return $output;
45+
}

0 commit comments

Comments
 (0)