[eluser]Unknown[/eluser]
A have few games in my application, and each game have some shared functionality. For each game i created library in application/libraries/games/ directory (all files are located in that directory). One game have one file which name is the same as game name.
Here is pseudocode for 'Writeitright' game:
file Writeitright.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Writeitright extends Game {
public function __construct() {
parent::__construct();
echo '2. Hello from child';
}
}
file Game.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Game {
$sharedProperty; // property available in child class
public function __construct() {
$this->sharedProperty = 1337;
echo '1. Hello from parent<br/>';
}
protected function SharedMethod() {
// method available in child class
}
}
in my controller file i have just:
Code:
$this->load->library('game/Writeitright');
I expected output like that:
Quote:1. Hello from parent
2. Hello from child
But i got only second line. I tried to add a prefix 'MY_' to my files and change class names to have prefix, but it does not work
I think that include Game.php file into Writeitright.php should help but is that a good way to solve problem?