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!