doumao1917 2013-11-03 13:46
浏览 75

致命错误:在第8行的C:\ xampp \ htdocs \ index.php中调用未定义的方法stdClass :: AddFile()[复制]

This question already has an answer here:

can someone please help, im getting this error:

Fatal error: Call to undefined method stdClass::AddFile() in C:\xampp\htdocs\index.php on line 8

***UPDATE This is NEW my index.php:

<?php
define('IN_INDEX', 1);
include ('inc.php');
$TPL = new CoreScript_TPL();
$TPL->TPLDir = 'themes/'.$hotel[temp].'';
if(!isset($_GET['page']) || $_GET['page'] == 'index') {

    $TPL->AddFile('index');


}

echo $TPL->Run();

?>

The inc.php contains some includes, to the config, a class.template.php and my core.tpl.php, witch is this:

<?php

class CoreScript_TPL {

    public $TPLData;
    public $TPLDir;
    public $TPLVars = array();

    function AddFile($FileName) {
        if(file_exists($this->TPLDir . '/' . $FileName . '.tpl')) {
            $this->TPLData .= file_get_contents($this->TPLDir . '/' . $FileName . '.tpl');
            return true;
        }
        else
            return false;
    }

    function AssignVar($Variable, $Value) {
        $this->TPLVars[$Variable] = $Value;
    }

    function Run() {
        $OutputData = $this->TPLData;
        foreach($this->TPLVars as $key => $value) {
            $OutputData = str_replace('{'.$key . '}', $value, $OutputData);
        }
        return $OutputData;
    }

}
 ?>

What is needs to do is request the theme name from the config.php and show that theme.. But it doesn't... Can someone please help??

By the way, sorry for my bad english, i'm dutch....

Thanks,

Wesley Peeters

**UPDATE:

my class.template.php

if (!empty($TPL)) {
//Dingen die met het hotel te maken hebben
$TPL->setParameter('longname', $_CONFIG['hotel']['longname']);
$TPL->setParameter('shortname', $_CONFIG['hotel']['shortname']);
$TPL->setParameter('theme', $_CONFIG['hotel']['template']);
$TPL->setParameter('ip', $_CONFIG['hotel']['ip']);
$TPL->setParameter('build', $_CONFIG['hotel']['webbuild']);
$TPL->TPLDir = 'themes/'.$theme.'';
//Dingen die met SWF's te maken hebben
$TPL->setParameter('ext_vars', $_CONFIG['swf']['externalvars']);
$TPL->setParameter('productdata', $_CONFIG['swf']['productdata']);
$TPL->setParameter('furnidata', $_CONFIG['swf']['furnidata']);
$TPL->setParameter('external_texts', $_CONFIG['swf']['externaltexts']);
$TPL->setParameter('swfpath', $_CONFIG['swf']['path']);
//Overige
$TPL->setParameter('twitteruser', $_CONFIG['social']['twitter']);
$TPL->setParameter('fbuser', $_CONFIG['social']['facebook']);



}
</div>
  • 写回答

1条回答 默认 最新

  • dongyuqie4322 2013-11-03 13:49
    关注

    You're missing the line to create $TPL as an instance of CoreScript_TPL:

    $TPL = new CoreScript_TPL();
    

    Without that, when you do $TPL->TPLDir = ..., PHP will create $TPL as a new, empty "stdClass" object, which won't have an AddFile method.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据