新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

PHP_CI框架(1)

一、错误处理:

创新互联公司-专业网站定制、快速模板网站建设、高性价比雅安网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式雅安网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖雅安地区。费用合理售后完善,十多年实体公司更值得信赖。

 1、show_error('错误信息','错误编号','错误标题');

 2、log_message($level, $message, $php_error = FALSE);写错误日志,需要修改config.php的threshold。

二、缓存页面:

 1、开启缓存:将$this->output->cache($n)置于控制器任意位置,$n为分钟数;

 2、代码删除缓存:$this->output->delete_cache();


三、程序分析:

 1、启动分析器:$this->output->enable_profiler(true);

 2、启动分析器:$this->output->enable_profiler(false);

 3、启动和禁用分析器字段:

   (1)修改config/profiler.php,如:$config['queries'] = true;

   (2)控制器调用输出类覆盖:$this->output->set_profiler_sections($arr);

PHP_CI框架(1)


四、基准测试类;

 1、在控制器中,直接调用

    $this->benchmark->mark('start');

    $this->benchmark->mark('end');

    echo $this->benchmark->elapsed_time('start','end');

   输出start到end的时间。

 2、在视图中添加benchmark->memory_usage();?>或者伪变量{memory_usage} 即可输出代码所用内存。


五、缓存驱动器:

 示例:

    $this->load->driver('cache',array('adapter'=>'apc','backup'=>'file'));

$mycache = $this->cache->get('my_first');

if(! $mycache){

$this->cache->save('my_first','测试1!',3);

$mycache = '侧四?';

}

var_dump($mycache);

var_dump(date('H:i:s',time()));

    var_dump($this->cache->cache_info()); //获取所有缓存信息;

    var_dump($this->cache->get_metadata('my_first')); //获取某缓存的保存时间;

六、日历类:

 示例:

    $prefs = array(

        'start_day'    => 'saturday',

         'month_type'   => 'long',

        'day_type'     => 'short'

    );

    $this->load->library('calendar',$prefs);

    $data = array(

        3  => 'http://example.com/news/article/2006/03/',

        7  => 'http://example.com/news/article/2006/07/',

        13 => 'http://example.com/news/article/2006/13/',

        26 => 'http://example.com/news/article/2006/26/'

    );

    echo '

';

    echo $this->calendar->generate(2017,3,$data); 

    echo '

';


七、购物车类:实际上是把数据存储到session中;

八、配置类:使用此功能,可以把要配置的业务需要配置的内容都放置到配置文件中;

 1、加载自己的配置文件:$this->config->load('文件名',true);注意,文件名是config目录下的文件,若使用config的子文件夹,则“文件 夹名/文件名”。

 2、修改配置信息:$this->config->set_item(键名,键值);

 3、可以直接使用$this->config->site_url()等方法。

九、邮箱类:

 1、首先要确保安装了邮件服务器,本人安装的是hMailServer;

 2、示例代码如下:

    //使用邮件

$this->load->library('email');

$this->email->from('linquan@ucpaas.com','林泉');

$this->email->to('1150895809@qq.com');

$this->email->cc('1150895809@qq.com');

$this->email->subject('测试邮件');

$this->email->message('林泉的帅气已经无人可挡!');

$this->email->send();

echo $this->email->print_debugger();

echo '

';

echo '执行完毕!';

echo '

';


分享名称:PHP_CI框架(1)
网站URL:http://www.wjwzjz.com/article/geggog.html
在线咨询
服务热线
服务热线:028-86922220
TOP