You are here: Include and extending classes « PHP « IT news, forums, messages
Include and extending classes

Posted by Mike Smith on 06/16/05 19:30

I'm trying to consolidate code in a new project. My dirs are:
/
/inc
core.class.php
/mods
/mods/system
system.class.php //extends core.class.php
user.class.php //extends system.class.php

In core.class.php I have my generic special html methods and my db
connection. I'm having trouble accessing $this->db (initialized in
core.class.php) from user.class.php. Am I wrong in thinking
user.class.php should be able to access methods/attributes of
core.class.php?
I'm running PHP 5.0.4 on Windows

//core.class.php

class core {

var $db;

function core(){
//initialize db connection (works from here)
}
//Other methods
}

//system.class.php
include "../../inc/core.class.php";
class system extends core {

function system(){

}
}

//user.class.php
include "system.class.php";
class user extends system{

function user(){
//$this->db cannot be used here
}
}

TIA,
Mike
"There are no stupid questions." --my professors until I came into class.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация