I'm creating a system like MVC.
I'm using below class when I want to call view files.
$fileName is index.php. Index.php has only
I want to print data in header.php like below:
But I'm getting errors.
What can i solve this problem?
Note: Please be careful! header.php is calling by Call class. header.php is inside of Call class.
I'm using below class when I want to call view files.
Code:
<?php
class Call{
function __construct($fileName) {
//$this->db = new Database;
self::callFile($fileName);
}
function callFile($fileName)
{
$this->title = "example";
$this->description = "example";
$this->keywords = "example";
$fileName = $fileName . '.php';
require PAGESPATH.'common/header.php';
require PAGESPATH.$fileName;
require PAGESPATH.'common/footer.php';
}
}
?>
Code:
Index Page..
Code:
<html>
<head>
<meta charset="utf-8">
<title><?php if(isset($this->title)){echo $this->title;} ?> - WebProgramlama.tk</title>
<meta name="description" content="<?php if(isset($this->description)){echo $this->description;}?>" />
<meta name="keywords" content="<?php if(isset($this->keywords)){echo $this->keywords;} ?>" />
</head>
<body>
Code:
Fatal error: Using $this when not in object context in /var/www/webprogramlama/class/pages/common/header.php on line 4
Note: Please be careful! header.php is calling by Call class. header.php is inside of Call class.
Comment