我想在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("/<a[^>]+>(.+?)<\/a>/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学的不是很好,求指点答对了另加分

解决方案 »

  1.   

    getUserType() 中有 if($this->userType != '')
    显然是对象的方法
    你 if(getUserType()==10) 当然是不行的这不是 MVC学的不是很好 问题,原因在于你并没有理解什么是函数,什么是方法。虽然都有 function 声明
      

  2.   

    我改成了if($cuserLogin->getUserType()==10)//(这个地方出错)仿照其他的用法还是报错
     Call to a member function getUserType() on a non-object。