codeigniter

如何捕获PHP致命错误

别等时光非礼了梦想. 提交于 2020-02-26 08:35:55
我可以使用 set_error_handler() 捕获大多数PHP错误,但是对于致命的( E_ERROR )错误(例如调用不存在的函数)不起作用。 还有另一种捕获这些错误的方法吗? 我正在尝试针对所有错误调用 mail() ,并且正在运行PHP 5.2.3。 #1楼 PHP具有可捕获的致命错误。 它们定义为E_RECOVERABLE_ERROR。 PHP手册将E_RECOVERABLE_ERROR描述为: 可捕获的致命错误。 它表明发生了可能是危险的错误,但没有使引擎处于不稳定状态。 如果错误未由用户定义的句柄捕获(另请参见 set_error_handler() ),则应用程序将中止,因为它是E_ERROR。 您可以通过使用 set_error_handler() 并检查E_RECOVERABLE_ERROR来“捕获”这些“致命”错误。 我发现捕获此错误时引发异常很有用,然后可以使用try / catch。 这个问题和答案提供了一个有用的示例: 如何在PHP类型提示中捕获“可捕获的致命错误”? 但是,可以处理E_ERROR错误,但由于引擎处于不稳定状态,因此无法从中恢复。 #2楼 我开发了一种方法来捕获PHP(几乎所有)中的所有错误类型! 我不确定E_CORE_ERROR(我认为仅不适用于该错误)! 但是,对于其他致命错误(E_ERROR,E_PARSE,E_COMPILE .

How to get back to the redirecting page after login (codeigniter)?

拥有回忆 提交于 2020-02-26 07:29:05
问题 I have login controller in my CI app: function index() { if($this->session->userdata('logged_in')==TRUE) redirect('/success'); $data['error']=$this->session->flashdata('errormessage'); $this->load->view('auth',$data); } function process_login() { $username=$this->input->post('username'); $password=$this->input->post('password'); if($password == "good_pwd") { $data=array('username'=>$username,'logged_in'=>TRUE); $this->session->set_userdata($data); redirect('/success'); } else { $this->session

CI session类

百般思念 提交于 2020-02-26 03:27:47
初始化 Session 类 Session 通常会在每个页面载入的时候全局运行,所以 Session 类必须首先被初始化。 您可以在 控制器 的构造函数中初始化它, 也可以在系统中 自动加载 。Session 类基本上都是在后台运行, 你不会注意到。所以当初始化 session 之后,系统会自动读取、创建和更新 session 数据 。 要手动初始化 Session 类,你可以在控制器的构造函数中使用 $this->load->library() 方法: $this -> load -> library ( ' session ' ); 初始化之后,就可以使用下面的方法来访问 Session 对象了: $this -> session 重要 由于 加载类 是在 CodeIgniter 的控制器基类中实例化的, 所以如果要在 你的控制器构造函数中加载类库 的话,确保先调用 parent::__construct() 方法。 1. session数据 session数据是个简单的数组,带有一个特定的session ID(cookie)。 CodeIgniter 使用了相同的方式来访问 session 数据,同时使用了 PHP 自带的 session 处理机制, 使用 session 数据和操作 $_SESSION 数组一样简单(包括读取,设置,取消设置)。 2. 获取 Session

PHP 框架 CodeIgniter 4.0 正式版发布了!

笑着哭i 提交于 2020-02-26 00:49:02
作者:Lonnie Ezell 原文:https://forum.codeigniter.com/thread-75581.html 今天我们隆重的宣布,完全重写的 CodeIgniter 4.0 正式版发布了!非常感谢所有贡献代码,撰写文档或提交 Issue 的朋友们。当你浏览市面上大多数的 PHP 框架时,你会发现其中大多数框架都具有某种形式的商业支持,但是对于 CodeIgniter 框架来说,是一些普普通通的开源贡献者们帮助了框架的发展,甚至在遇到一些挑战时仍在继续坚持。 回首过去,我第一次提交代码是在 2015 年 8 月 26 日。当时,我只是凭兴趣自愿提供一些代码,我从未想过我会成为这个项目的首席开发人员,但当时由于其他团队成员的时间问题,我担任了这个看起来容易的职位。在最初的三年左右的时间里,我一直在用业余时间编写代码,努力实现自己的承诺。这些年来,我有好几次想停下来,我想去开发一些更可能完成的东西,例如我想探索的四个主要思想中的任何一个,是你们让我坚持了下去。 在过去的一年半中,你们中的许多人都挺身而出,以帮助将该项目推向终点。到今天,如果没有大家的帮助这是不可能发生的。 不幸的是,一切并不都是美好的,因为我们最近因肺癌失去了出色的项目负责人 James Perry。他的杰出贡献使得这次 4.0 版的发布成为可能。今天是他的生日,James 生日快乐! --

为什么@ font-face在woff文件上引发404错误?

梦想的初衷 提交于 2020-02-25 19:13:31
我在公司网站上使用 @font-face ,它工作正常/看起来很棒。 除Firefox和Chrome以外, .woff 文件将引发404错误。 IE不会引发错误。 我的字体位于根目录,但我尝试使用css文件夹中的字体,甚至提供字体的整个URL。 如果从我的css文件中删除那些字体,我不会得到404,所以我知道这不是语法错误。 另外,我使用了fontsquirrels工具来创建 @font-face 字体和代码: @font-face { font-family: 'LaurenCBrownRegular'; src: url('/laurencb-webfont.eot'); src: local('☺'), url('/laurencb-webfont.woff') format('woff'), url('/laurencb-webfont.ttf') format('truetype'), url('/laurencb-webfont.svg#webfontaaFhOfws') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'FontinSansRegular'; src: url('/fontin_sans_r_45b-webfont.eot');

How can I store validation errors related to image upload as flash massages in this Codeigniter 3 application?

房东的猫 提交于 2020-02-25 04:07:38
问题 I am working on a basic blog application with Codeigniter 3.1.8 and Bootstrap 4 . The posts, of course, have main images. There is a default image if no image is uploaded by the user. There are restrictions on image files a user can upload: $config['upload_path'] = './assets/img/posts'; $config['allowed_types'] = 'jpg|jpeg|png'; $config['max_size'] = '2048'; I have managed to display the upload error messages that correspond to the configuration above (for your curiosity and/or use, the code

How can I store validation errors related to image upload as flash massages in this Codeigniter 3 application?

白昼怎懂夜的黑 提交于 2020-02-25 04:06:18
问题 I am working on a basic blog application with Codeigniter 3.1.8 and Bootstrap 4 . The posts, of course, have main images. There is a default image if no image is uploaded by the user. There are restrictions on image files a user can upload: $config['upload_path'] = './assets/img/posts'; $config['allowed_types'] = 'jpg|jpeg|png'; $config['max_size'] = '2048'; I have managed to display the upload error messages that correspond to the configuration above (for your curiosity and/or use, the code

Search multiple table data in codeigniter

大城市里の小女人 提交于 2020-02-25 04:04:08
问题 The table you select when searching the zipcode brings in data from the selected DB table. But I do not know how to do it. Please help me. I have 3 table in my database tblcaregiver. tblfamily, tblprovider. This is the process I want to search.. This is DB table... View <div class="serc-title">Search User</div> <div> <div class="input-group mb-4"> <form action="<?php echo site_url('provider/dashboard/search_keyword');?>" method="post"> <input type="text" name = "keyword" required="required"

CodeIgniter配置之SESSION

别来无恙 提交于 2020-02-25 02:41:05
刚使用Codeigniter时也被其中的SESSION迷惑过,后来就再也没用过CI自带的SESSION,想必还是有必要整理一下SESSION。为弄清CI中的SESSION,先来说一下PHP中SESSION是如何工作的。由于HTTP协议本身是无状态的,所以当保留某个用户的访问状态信息时,需要客户端有一个唯一标识传给服务端,这个唯一标识就是SESSION ID,存放在客户端的COOKIE中,然后服务端根据该标识读取存放的用户状态信息,达到保存会话状态的目的。PHP中启动一个会话需要执行下面语句: 1 session_start(); 1、客户端每次请求时会有一些信息存放中HTTP头中发送给服务端,以用户第一次访问为例: Request Headers Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip,deflate,sdch Accept-Language:zh-CN,zh;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Host:s.local User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML,

CodeIgniter flashdata not working after redirect

时光怂恿深爱的人放手 提交于 2020-02-25 02:38:07
问题 I have set the flash data like this $this->session->set_flashdata('dispMessage','my message is here')); I found that message in session library but not display in redirect page. and I am use the codeigniter version 2.2.0. Can anyone help...? 回答1: According to the session class page of the manual: CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared. These can be very useful, and are typically used for