CI 笔记,借鉴的4个辅助自定义函数

在System的core的common.php中,借鉴的4个自定义函数,

摘自后盾网的CI教程

/**
 * 格式化打印函数
 * @param  [type] $arr [数组]
 * @return [type]      [description]
 */
function p($arr){
    echo '<pre>';
    print_r($arr);
    echo '</pre>';
}
// admin/category/index
/**
 * 成功提示函数
 * @param  [type] $url [跳转地址]
 * @param  [type] $msg [提示信息]
 * @return [type]      [description]
 */
function success($url, $msg){
    header('Content-Type:text/html;charset=utf-8');
    $url = site_url($url);
    echo "<script type='text/javascript'>alert('$msg');location.href='$url'</script>";
    die;
}

/**
 * 错误提示函数
 * @param  [type] $msg [提示信息]
 * @return [type]      [description]
 */
function error($msg){
    header('Content-Type:text/html;charset=utf-8');
    echo "<script type='text/javascript'>alert('$msg');window.history.back();</script>";
    die;
}


/**
 * 打印常量
 */
function print_const(){
    $const = get_defined_constants(TRUE);
    p($const['user']);    
}
原文地址:https://www.cnblogs.com/sdgtxuyong/p/5486163.html