Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
{PHP}致命错误:不在对象上下文中使用$this(Joomla)_Php_Joomla - Fatal编程技术网

{PHP}致命错误:不在对象上下文中使用$this(Joomla)

{PHP}致命错误:不在对象上下文中使用$this(Joomla),php,joomla,Php,Joomla,我真的不懂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 d

我真的不懂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>


任何帮助都会很好,因为我完全迷路了。

错误是不言自明的。看起来这一点让它窒息了:

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

$this
仅用于类方法内部。试着找出“语言”的实际定义。你可以试着用
$language
替换
$this->language
,但我不知道你的东西是如何设置的

Edit:实际上,在此之前,您似乎根本没有任何
include
语句。。。因此,不应定义任何内容。除非您的
index.php
文件中包含了其他内容,但是包含索引有点不寻常


如果你从某个地方复制了Joomla模板,你可能会把它放错地方。

那么你只能在类内部使用
$this
。在类之外,
$this
不应该存在。它基本上引用了您在其中工作的当前类对象。要使其正常工作,需要将变量定义为新类,然后通过该变量引用所有内容,例如:

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

如果这是你正在做的事情。

哈哈。。抱歉,bb代码不起作用;)好的尝试!我真的不确定我在做什么,我没有php的知识,真的不明白,我会尝试你们的建议。另外,在发布代码时,代码是什么?我们会让你们知道我的进展