优化代码
This commit is contained in:
43
vendor/topthink/framework/src/helper.php
vendored
43
vendor/topthink/framework/src/helper.php
vendored
@@ -202,6 +202,34 @@ if (!function_exists('dump')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dd')) {
|
||||
/**
|
||||
* 浏览器友好的变量输出
|
||||
* @param mixed $vars 要输出的变量
|
||||
* @return void
|
||||
*/
|
||||
function dd(...$vars)
|
||||
{
|
||||
ob_start();
|
||||
var_dump(...$vars);
|
||||
|
||||
$output = ob_get_clean();
|
||||
$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
|
||||
|
||||
if (PHP_SAPI == 'cli') {
|
||||
$output = PHP_EOL . $output . PHP_EOL;
|
||||
} else {
|
||||
if (!extension_loaded('xdebug')) {
|
||||
$output = htmlspecialchars($output, ENT_SUBSTITUTE);
|
||||
}
|
||||
$output = '<pre>' . $output . '</pre>';
|
||||
}
|
||||
|
||||
echo $output;
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('env')) {
|
||||
/**
|
||||
* 获取环境变量值
|
||||
@@ -661,3 +689,18 @@ if (!function_exists('root_path')) {
|
||||
return app()->getRootPath() . ($path ? $path . DIRECTORY_SEPARATOR : $path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_dev')) {
|
||||
function is_dev()
|
||||
{
|
||||
$env = env('APP_ENV', '');
|
||||
$env = strtolower($env);
|
||||
if (in_array($env, ['dev', 'development', 'local', 'test'], true)) {
|
||||
return true;
|
||||
}
|
||||
if (app()->environment('dev') || app()->environment('local') || app()->environment('test')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user