码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-05-13 10:43:09      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

在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‘]);    
}

 

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

标签:

原文地址:http://www.cnblogs.com/sdgtxuyong/p/5486163.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!