---
title: "Joomla 2.5 Templates &#8211; $this->"
description: "We are continuing to review Joomla 2.5's Beez2 template code, and we next come accross the following code: &lt;html xmlns=\"https://www.w3.org/1999/xhtml\" xml:lang=\"&lt;?php echo $this-&gt;language;..."
url: https://www.inmotionhosting.com/support/edu/joomla/joomla-2-5/this/
date: 2012-07-19
modified: 2021-08-16
author: "Brad Markle"
categories: ["Joomla", "Joomla 2.5"]
tags: ["Joomla v2.5"]
type: post
lang: en
---

# Joomla 2.5 Templates &#8211; $this->

We are continuing to review Joomla 2.5's Beez2 template code, and we next come accross the following code:

<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="<?php echo **$this->**language; ?>" lang="<?php echo **$this->**language; ?>" dir="<?php echo **$this->**direction; ?>" >

In our review thus far, we have alread seen instances of **$this->**, for example:

- [$showRightColumn](/support/edu/joomla/joomla-2-5/showrightcolumn/)
- [$this->countModules](/support/edu/joomla/joomla-2-5/this-countmodules/)
- [$this->params->get](/support/edu/joomla/joomla-2-5/this-params-get/)

## What is $this-> ?

Technically speaking, in PHP $this refers to the current object. PHP will set the contents of $this when you are inside a function of an object.

If we update our template's code as follows, we can see more information about $this:

**<? echo "<pre>"; print_r($this); echo "</pre>"; die(); ?>** <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >

The output above is quite long, and below we've included the first few lines only:

JDocumentHTML Object
(
[_links] => Array
(
=> Array
(
=> alternate
=> rel
=> Array
(
=> application/rss+xml
=> RSS 2.0
)

Based upon the first line, $this appears to be referring to the **JDocumentHTML Object**, which we touched based on in a [previous article](/support/edu/joomla/joomla-2-5/jfactory-get-document/).

## When is $this-> used in the Beez2 template?

When scanning the index.php file of the Beez2 template, there are several uses of **$this**:

- [$this->countModules()](/support/edu/joomla/joomla-2-5/this-countmodules/)
- [$this->params->get()](/support/edu/joomla/joomla-2-5/this-params-get/)
- [$this->baseurl](/support/edu/joomla/joomla-2-5/this-baseurl/)
- [$this->template](/support/edu/joomla/joomla-2-5/this-template/)
- [$this->language](/support/edu/joomla/joomla-2-5/this-language/)
- [$this->direction](/support/edu/joomla/joomla-2-5/this-direction/)
