DUBECZ
Новичок
Ку всем!
В общем есть три класса:
Могу же я сделать так чтоб два или более классов наследовали CORE?
Вопрос та в чем как их правильно обьявить?
я писал:
$core = new core();
$core = new temp(); когда были классы только эти все работало, но как только добавил $core = new registration(); начало ругаться, а именно
Fatal error: Call to undefined method core::compile_page() in A:\home\localhost\www\ENGINE\index.php on line 12
если важно вот функция:
вот INDEX
В общем есть три класса:
PHP:
class core{
тут всякие методы и тому подобное....
}
class temp extends core{
тут всякие методы и тому подобное....
}
class regisrtation extends core{
тут всякие методы и тому подобное....
}
Вопрос та в чем как их правильно обьявить?
я писал:
$core = new core();
$core = new temp(); когда были классы только эти все работало, но как только добавил $core = new registration(); начало ругаться, а именно
Fatal error: Call to undefined method core::compile_page() in A:\home\localhost\www\ENGINE\index.php on line 12
если важно вот функция:
PHP:
function compile_page($name_page){
$this -> index_content = file_get_contents(INDEX_TEMP);//достаем index шаблон
$this -> index_content = str_replace('[!DOCTYPE!]', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', $this -> index_content);//вставляем DOCTYPE
preg_match_all('/([a-zA-Z]+)\.([a-z]+)/i', $this -> index_content, $array);//ищем места вставки CSS и JS
foreach($array[2] as $kay => $val){//вставляем CSS и JS
if($val == 'css') {
$this -> index_content = str_replace('['.$array[0][$kay].']', '<link rel="stylesheet" href="'.PATH_CSS.$array[0][$kay].'" type="text/css" />', $this -> index_content);
}
if($val == 'js') {
$this -> index_content = str_replace('['.$array[0][$kay].']', '<script src="'.PATH_SCRIPT.$array[0][$kay].'"></script>', $this -> index_content);
}
}
$this -> index_content = $this -> read_block($this -> index_content);//вставляем блоки
//тут выводим mainbody
if(isset($name_page)){
$divided_val = explode("-", $name_page);
if($divided_val[0] == 'mod'){
switch($divided_val[1]){
case 'registration':
$this -> index_content = str_replace('[title]', 'Регистрация', $this -> index_content);
$this -> index_content = str_replace('[/mainbody/]', 'registration', $this -> index_content);
break;
default:
$this -> index_content = str_replace('[title]', 'Ошибка 404', $this -> index_content);
$this -> index_content = str_replace('[/mainbody/]', $this -> error_message('Такой страницы несуществует'), $this -> index_content);
}
}elseif($divided_val[0] == 'user'){
if($this -> user_exist($divided_val[1]) == 0){
$this -> index_content = str_replace('[title]', 'Ошибка! ', $this -> index_content);
$this -> index_content = str_replace('[/mainbody/]', $this -> error_message('Такого пользователя нет: '.$divided_val[1]), $this -> index_content);
}else{
$this -> index_content = str_replace('[title]', 'Страница пользователя '.$divided_val[1], $this -> index_content);
$this -> index_content = str_replace('[/mainbody/]', 'Пользователь '.$divided_val[1].' сушествует', $this -> index_content);
}
}else $this -> index_content = str_replace('[/mainbody/]', 'тут должен быть модуль ПОУМОЛЧАНИЮ', $this -> index_content);
}
вот INDEX
PHP:
<?php
#################
####INDEX.PHP####
#################
include_once("system/core/path_config.php");
include_once("system/core/core.class.php");//подключаем ядро
include_once("system/core/templating.class.php");
include_once("system/core/registration.func.php");
$core -> connect_to_db();
$core -> compile_page($core -> security_function($_GET['page']));
?>