CI 묻고 답하기

제목 CLE 의 MY_PageController 의 의문점
글쓴이 터프키드 작성시각 2009/11/23 17:54:22
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 30943   RSS
전에는 CLE 의 세개 파일 pagecontroller, loader, controller 를 그대로 넣고 잘 썼는데요
1.7.2 버전의 문제인지 이번에는 아래와 같은 에러를 뿜어내네요;;

A PHP Error was encountered

Severity: Warning

Message: The magic method __get() must have public visibility and cannot be static

Filename: libraries/MY_PageController.php

Line Number: 8

A PHP Error was encountered

Severity: Warning

Message: The magic method __call() must have public visibility and cannot be static

Filename: libraries/MY_PageController.php

Line Number: 14

해서 MY_PageController.php 를 보니 아래와 같았습니다.
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_PageController extends MY_Controller {
  function __construct()
	{
		parent::getInstance();	
	}
	  
  protected function __get($var){
    if(isset(parent::$instance->$var)) {
      return parent::$instance->$var;
    }
  }

  protected function __call($name, $arguments) {  
    if(method_exists(parent::$instance,$name))
    call_user_func_array(array(parent::$instance, $name), $arguments);
  }
}

/* End of file MY_PageController.php */
/* Location: ./system/application/libraries/MY_PageController.php */

__get 이나 __set , __call() 등의 메소드는 기본적으로 public 으로 선언되어야 하는데 protected로 선언되어있네요
근데 왜 1.7.1 에서는 정상적으로 돌아갔을까요?

public 으로 고쳐서 정상적으로 작동은 하는데 궁금하네요;
 다음글 [초보질문]mysql_real_escape_string... (3)
 이전글 [초보질문] BR 테그에 관하여~ (2)

댓글

byung82 / 2009/11/23 17:58:51 / 추천 0
아마도 예상은 protected call 을 체크하는게 더 들어갔다고 보는게 맞을것 같습니다.
오류내용도 보면
The magic method __get() must have public visibility and cannot be static
magic 함수는 꼭 필히 public으로 해달라고 말이 있으니 ㅎㅎ 그렇게 고쳐주시는게 맞는거 입니다.

그럼
ci세상 / 2009/11/23 23:12:05 / 추천 0

php 버젼이 바뀌신것 같은데요.. php 5.3에서는 위와 같은 문법은 오류가 납니다.

php 메뉴얼을 참조해 주세요.
http://www.php.net/manual/en/language.oop5.overloading.php