2010-04-08 64 views
2

我並不真正瞭解php並且遇到了一堵磚牆。

的問題是,我的網站顯示以下錯誤......

Fatal error: Using $this when not in object context in /hermes/web07/b2350/pow.thefoodie/htdocs/index.php on line 11 

這是我的index.php文件的開頭...

<?php 
/* 
    Joomla templates by Joomladesigns.co.uk 
*/ 

// no direct access 
define('YOURBASEPATH', dirname(__FILE__)); 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" > 
<head> 
<jdoc:include type="head" /> 
<!--[if lte IE 6]> 
<style type="text/css"> 
#main_body ul li { behavior: url(<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/css/iepngfix.htc) } 
</style> 
<script defer type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/js/pngfix.js"></script> 
<![endif]--> 
<link href="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/css/template_css.css" rel="stylesheet" type="text/css" media="all" /> 
<script type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/js/fx_styles.js"></script> 
<script type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/js/accordion.js"></script> 

<?php 

// ************************************************* 
// 
// Template Parameters 
// 
// ************************************************* 

$h1   = $this->params->get("logo"); 
$linked_h1 = ($this->params->get("logoLinked", 1) == 0)?"false":"true"; 
$h1_title = $this->params->get("logoTitle"); 
$h2_motto = $this->params->get("logoMotto"); 

// Please do NOT change this unless you know what you doing. 

$template_path = $this->baseurl.'/templates/'.$this->template; // template path 

$default_font = "default"; 


// ************************************************** 

?> 

</head> 

任何幫助將是巨大的因爲我完全失去了。

+1

哈哈..對不起,bb代碼不起作用;)雖然不錯! – mpen 2010-04-08 06:14:13

+0

我真的不知道我在做什麼,我沒有真正的PHP知識,不明白它,我會嘗試你們的建議。還有什麼是在發佈時放置代碼的代碼? Thnaks傢伙,我會讓你知道我怎麼去 – Asher 2010-04-08 07:21:08

回答

1

該錯誤是不言自明的。看起來像它窒息此位:

<?php echo $this->language; ?> 

$this只是意味着類方法中使用。嘗試找出「語言」實際定義的位置。您可以嘗試用$language代替$this->language,但我不知道您的東西是如何設置的。

編輯:事實上,它看起來並不像你有在所有在此之前,任何include陳述......所以什麼應該被定義。除非其他文件包含您的index.php文件,但對於要包含的索引來說有點不尋常。

如果您從某處複製了Joomla模板,那麼您可能會把它放在錯誤的地方。

1

那麼你只能在課堂上使用$this。課外,$this不應該存在。它基本上引用了你正在工作的當前類對象。爲了得到這個正常工作,你需要定義一個變量作爲一個新的類,然後通過該變量引用的一切,如:

$myvar = new MyClass(); 
$h1 = $myvar->params->get("logo"); 

如果是這樣的事情你做的那種。

相關問題