Home >Backend Development >PHP Tutorial > DEDECMS控制器修改有关问题。小弟我MVC学的不是很好

DEDECMS控制器修改有关问题。小弟我MVC学的不是很好

WBOY
WBOYOriginal
2016-06-13 13:12:27826browse

DEDECMS控制器修改问题。。我MVC学的不是很好
我想在dede/inc/inc_archives_functions.php加入include里的userlogin.class.php
/**
  * 获得用户的权限值
  *
  * @access public
  * @return int
  */
userlogin.class.php文件:
function getUserType()
  {
  if($this->userType != '')
  {
  return $this->userType;
  }
  else
  {
  return -1;
  }
  }
但是我的inc_archives_functions.php文件代码是
function GetCurContent($body)
{
require_once(DEDEINC.'/userlogin.class.php');
if(getUserType()==10)(这个地方出错)
  {
  $body=preg_replace("/]+>(.+?)/i","$1",$body);(测试过没问题)
  }
.........报错
Fatal error: Call to a member function getUserType() on a non-object in 
E:\wamp\www\dede\inc\inc_archives_functions.php on line 114
请问有人能帮忙回答下吗不胜感激,我MVC学的不是很好,求指点答对了另加分

------解决方案--------------------
getUserType() 中有 if($this->userType != '')
显然是对象的方法
你 if(getUserType()==10) 当然是不行的

这不是 MVC学的不是很好 问题,原因在于你并没有理解什么是函数,什么是方法。虽然都有 function 声明

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn