I've been playing with OOP for a bit now and I'm liking the way it's working so far (it's a lot more condensed!), but at the moment I have one 'main' class which has all of the functions. Problem is, this file is included in every page and some of the functions are only relevant to very few pages, so I moved the barely used ones into a file to be included. This is where I discovered you couldn't add a function to a class by including it directly - is this where you need a new class to extend the first?
Here's a snippet of init.class.php (which calls rss.inc.php):
Code: Select all
if (!defined('ACTIVE')) {header("Location: ../login.php"); exit;}
class init {
private $testmode,$dbname;
...
public function __construct() {
...
}
public function get_rss() {
if (file_exists($this->libpath.'rss.inc.php')) {
require_once($this->libpath.'rss.inc.php');
$rss = new rss_parse;
return true;
}
return false;
}
# many more functions ...
}Ideally I would really like to be able to extend the class init so all the functions of rss_parse become available through $app, is that possible? Any help would really be appreciated!
Thanks, Ben
P.S. here's a little snippet of rss.class.php:
Code: Select all
...
class rss_parse extends init {
public function rss_parse() {
# do nothing
}
# the rss parsing functions
...
}