---
title: "unexpected T_VARIABLE"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/165519-unexpected-t-variable"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "yador"
published: "2007-10-15T14:54:20.000Z"
updated: "2007-10-15T19:10:58.000Z"
replies: 2
views: 441
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/165519-unexpected-t-variable"
---

# unexpected T_VARIABLE

## #1 — yador, 2007-10-15T14:54Z

Hejsan!
Så här ser **page.php** ut

```
<?php

class Page {
	var $dtd;
	var $title;
	var $meta;
	var $csslink;
	var $script;
	var $body;
	
	function Page() {
		$this->dtd = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">";
		
	}
	
	function setDTD($dtd){
		$this->dtd = $dtd;
	}
	
	function getDTD(){
		return $this->dtd;
	}
	
	function setTitle($title){
		$this->title = $title;
	}
	
	function getTitle(){
		return $this->title;
	}
	
	function metaSize(){
		$i = 0;
		while(isset($this->meta[$i])) {
			$i++;
		}
		return $i;
	}

	function addMetaTag($metatag){
		$this->meta[$this->metaSize()+1] = $metatag;
	}
	
	function eraseMetaTag($which = All){
		if($which == "All"){
			$this->meta = "";
			return;
		}
		if(!is_numeric($which)){
			return;
		}
		$copy;
		$i;
		for($i=0;$i<$which;$i++){
			$copy[$i] = $this->meta[$i];
		}
		$i++;
		while(isset($this->meta[$i])) {
			$copy[$i-1] = $this->meta[$i];
		}
	}
	
	function getMetaTag($which = ALL){
		if($which == "ALL"){
			$ret;
			$i = 0;
			while(isset($this->meta[$i])) {
				$ret = $ret - $this->meta[$i];
				$i++;
			}
			return ret;
		}	
		if(is_numeric($which) && isset($this->meta[$which])){
			return $this->meta[$which];
		}
	}

	function addCssLink($csslink){
		$this->csslink = $this->csslink . $csslink;
	}
	
	function eraseCssLinks(){
		$this->csslink = "";
	}
	
	function draw() {
		print $this->dtd . "\n";
		print "<html>\n";
		print "<head>\n";
		if(isset($this->title)){
			print "<title>" . $this->title . "</title>\n";
		}
		if(isset($this->meta)){
		print $this->meta . "\n";
		}
		if(isset($this->csslink) && $this->csslink != ""){
			print "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $this->csslink . "\" />\n";
		}
		if(isset($this->script)){
		print $this->script . "\n";
		}
		print "</head>\n";
		print "<body>\n";
		print $this->body;
		print "</body>\n";
		print "</html>\n";
	}
}

class XPage {
	$page = new Page();
}

?>
```

Och såhär ser **index.php** ut.

```
require("../classes/page.php");
$a = new XPage();
```

Och detta felet får jag:

```
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /srv/www/htdocs/hemsidor/projektx/classes/page.php on line 111
```

Hur kan jag åtgärda det? Håller nämligen på att lära mig php och förstår ingenting.

Tack på förhand!

Permalänk: https://www.webforum.nu/p/165519

## #2 — colione, 2007-10-15T15:28Z

```php
<?php

class Page {
	var $dtd;
	var $title;
	var $meta;
	var $csslink;
	var $script;
	var $body;
	
	function Page() {
		$this->dtd = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">";
		
	}
	
	function setDTD($dtd){
		$this->dtd = $dtd;
	}
	
	function getDTD(){
		return $this->dtd;
	}
	
	function setTitle($title){
		$this->title = $title;
	}
	
	function getTitle(){
		return $this->title;
	}
	
	function metaSize(){
		$i = 0;
		while(isset($this->meta[$i])) {
			$i++;
		}
		return $i;
	}

	function addMetaTag($metatag){
		$this->meta[$this->metaSize()+1] = $metatag;
	}
	
	function eraseMetaTag($which = All){
		if($which == "All"){
			$this->meta = "";
			return;
		}
		if(!is_numeric($which)){
			return;
		}
		$copy;
		$i;
		for($i=0;$i<$which;$i++){
			$copy[$i] = $this->meta[$i];
		}
		$i++;
		while(isset($this->meta[$i])) {
			$copy[$i-1] = $this->meta[$i];
		}
	}
	
	function getMetaTag($which = ALL){
		if($which == "ALL"){
			$ret;
			$i = 0;
			while(isset($this->meta[$i])) {
				$ret = $ret - $this->meta[$i];
				$i++;
			}
			return ret;
		}	
		if(is_numeric($which) && isset($this->meta[$which])){
			return $this->meta[$which];
		}
	}

	function addCssLink($csslink){
		$this->csslink = $this->csslink . $csslink;
	}
	
	function eraseCssLinks(){
		$this->csslink = "";
	}
	
	function draw() {
		print $this->dtd . "\n";
		print "<html>\n";
		print "<head>\n";
		if(isset($this->title)){
			print "<title>" . $this->title . "</title>\n";
		}
		if(isset($this->meta)){
		print $this->meta . "\n";
		}
		if(isset($this->csslink) && $this->csslink != ""){
			print "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $this->csslink . "\" />\n";
		}
		if(isset($this->script)){
		print $this->script . "\n";
		}
		print "</head>\n";
		print "<body>\n";
		print $this->body;
		print "</body>\n";
		print "</html>\n";
	}
}

class XPage {
	var $page;
	
	function XPage() {
	$this->page=new Page();
	}
}

?>
```

Permalänk: https://www.webforum.nu/p/2039096

## #3 — yador, 2007-10-15T19:10Z

Tack!

Permalänk: https://www.webforum.nu/p/2039145

---

Tråden på webben: https://www.webforum.nu/amne/php/165519-unexpected-t-variable
