{PHP} Fatal error: Using $this when not in object context (Joomla)({PHP} 致命错误:不在对象上下文中使用 $this (Joomla))
问题描述
我真的不懂 php 并且碰壁了.
i don't really know php and have hit a brick wall.
问题是我的网站显示以下错误...
The problem is that my site is showing the following error...
Fatal error: Using $this when not in object context in /hermes/web07/b2350/pow.thefoodie/htdocs/index.php on line 11
这是我的 index.php 文件的开头...
This is the begining of my index.php file...
<?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="Jmx0Oz9waHAgZWNobyAkdGhpcy0mZ3Q7YmFzZXVybDsgPyZndDsvdGVtcGxhdGVzLyZsdDs/cGhwIGVjaG8gJHRoaXMtJmd0O3RlbXBsYXRlID8mZ3Q7L2pzL3BuZ2ZpeC5qcw=="></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="Jmx0Oz9waHAgZWNobyAkdGhpcy0mZ3Q7YmFzZXVybDsgPyZndDsvdGVtcGxhdGVzLyZsdDs/cGhwIGVjaG8gJHRoaXMtJmd0O3RlbXBsYXRlID8mZ3Q7L2pzL2Z4X3N0eWxlcy5qcw=="></script>
<script type="text/javascript" src="Jmx0Oz9waHAgZWNobyAkdGhpcy0mZ3Q7YmFzZXVybDsgPyZndDsvdGVtcGxhdGVzLyZsdDs/cGhwIGVjaG8gJHRoaXMtJmd0O3RlbXBsYXRlID8mZ3Q7L2pzL2FjY29yZGlvbi5qcw=="></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>
任何帮助都会很棒,因为我完全迷失了.
Any help would be great as i am completely lost.
推荐答案
好吧,您只能在类中使用 $this.在类之外,$this 不应该存在.它基本上引用了您在其中工作的当前类对象.要使其正常工作,您需要将一个变量定义为一个新类,然后通过该变量引用所有内容,例如:
Well you can only use $this inside of a class. Outside of a class, $this shouldn't exist. It basically references the current class object that you're working inside of. To get this working properly, you need to define a variable as a new class and then reference everything through that variable, such as:
$myvar = new MyClass();
$h1 = $myvar->params->get("logo");
如果那是你正在做的事情.
If that's the kind of thing you're doing.
这篇关于{PHP} 致命错误:不在对象上下文中使用 $this (Joomla)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:{PHP} 致命错误:不在对象上下文中使用 $this (Joomla)
- PHP Count 布尔数组中真值的数量 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Laravel 仓库 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
