| 제목 | [코어확장] null 경고문구 없애기 | ||
|---|---|---|---|
| 글쓴이 | ci세상 | 작성시각 | 2009/08/21 13:20:19 |
|
|
|||
|
- 질문 : http://codeigniter-kr.org/qna/view/809/page/1 - 논쟁 : http://codeigniter.com/forums/viewthread/48522 - 결론 : isset 이나 @ 같은것으로 코드를 더 복잡하게 하는것보다 개발자의 뜻에 따라서 코어확장시켜서 상황대처^^ 아래 코드는 에러메세지 중에서 Undefined variable 가 있을때만 잡아주게 했습니다. application/libraries/MY_Exceptions.php 로 새로 만드셔서 사용하시면 됩니다.
<?php
class MY_Exceptions extends CI_Exceptions
{
public function __construct()
{
parent::__construct();
}
function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace("\\", "/", $filepath);
// For safety reasons we do not show the full file path
if (FALSE !== strpos($filepath, '/'))
{
$x = explode('/', $filepath);
$filepath = $x[count($x)-2].'/'.end($x);
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/error_php'.EXT);
$buffer = ob_get_contents();
ob_end_clean();
//$msg_var = explode(":",$message);
//if($msg_var[0] != "Undefined variable") echo $buffer;
$error_tot = 0;
if(preg_match_all("/.*(variable)/", $message, $matchs))
{
if($matchs[1]) $error_tot++;
}
if(preg_match_all("/.*(index)/", $message, $matchs))
{
if($matchs[1]) $error_tot++;
}
if($error_tot == 0) echo $buffer;
}
}
|
|||
| 다음글 | [추천] CI 일본 개인블로그 주소들 (2) | ||
| 이전글 | [예제] 랜덤문자열 생성 (1) | ||
|
emc
/
2009/08/21 13:40:38 /
추천
0
라이브러리 추가하고, autoload.php 에 추가만 하면 되나요?
|
|
변종원(웅파)
/
2009/08/21 13:43:50 /
추천
0
라이브러리만 추가하시면 됩니다. |
|
ci세상
/
2009/08/21 16:53:02 /
추천
0
이렇게 해두니 CI 가 아닌소스들 마구 가져다 붙여도 되네요 ^^
|
|
ci세상
/
2009/09/11 13:35:52 /
추천
0
에러문구별 특정상황을 예외처리하도록 정규식 코드로 변경되었습니다.
|