Bootstrap.php
<?php
class KosLib
{
function __construct()
{
if(!class_exists('Database')){
include_once('/var/www/KosLib/config/database.php');
$this->db = new Database();
}
if(!class_exists('Kenteken')){
include_once('/var/www/KosLib/classes/kenteken.php');
$this->kenteken = new Kenteken();
}
}
}
<?php
class Kenteken extends KosLib
{
function __construct()
{
parent::__construct();
}
function getPlateTypes()
{
$sql = 'SELECT
ordernr,
description
FROM
kentekens';
return $this->db->query($sql);
}
}
?>
index.php
<?php
ini_set('display_errors', 1);
include('/var/www/KosLib/bootstrap.php');
$KL = new KosLib;
foreach($KL->kenteken()->getPlateTypes() as $plateType)
{
echo $plateType->description.'<br />';
}
?>
Foutmelding:
Fatal error: Call to undefined method KosLib::kenteken() in /var/www/Testhoek/index.php on line 8
Ik snap dat er iets fout gaat, en ook wel ongeveer wat er fout gaat, maar, hoe los ik het op en krijg ik het werkend?