TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-21-2009, 07:39 PM   #1 (permalink)
The Visitor
 
Etheco's Avatar
 
Join Date: Oct 2009
Posts: 4
Thanks: 0
Etheco is on a distinguished road
Help Classes (Explained inside)

Hi There as you can tell i am new to the community so firstly.

Hey all :D

Right to go into my problem. This is to write my own class base and core system. Read the code below to understand me further.

So all classes below will be seperate files. and will be included seperatly.

PHP Code:
class Base {
   public function 
load_class($class_name) { 
      include(
'core/'.$class_name.'.class.php');
      
$this->$class_name = new $class_name();
      }
}

class 
Logging {
   public function 
error($msg) {
      
print_r($msg);
      }

}

class 
Database extends Base {
   public function 
connect($coninfo) {
      
$this->Logging->error($coninfo);
      }

}

include(
'core/Base.class.php');
$Base = new Base();

$Base->load_class('Logging');
$Base->load_class('Database');
$Base->Database->connect('info'); 
Ok it all works up untill i run the connect, when i try to use $this->Logging->error(); it produces a error

Fatal error: Call to a member function error() on a non-object

Hope i explained it ok :(. Basicly i need to be able to use the classes i setup in the Base obj.

Thank you so so much in advanced :D
Etheco is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Abstract Classes sketchMedia Advanced PHP Programming 18 02-28-2013 05:38 AM
HTML Inside the class? Sirupsen General 16 06-06-2009 10:03 AM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM
no "include"s inside classes? pipesportugal Absolute Beginners 8 06-08-2008 04:58 PM
PHP5 Classes A to Z Part 1 quantumkangaroo Advanced PHP Programming 11 04-01-2008 04:21 AM


All times are GMT. The time now is 12:08 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design