Quick question regarding OOP Theory really.
Say you have a 'Page' class, which returns a page object that has methods such as getTitle(), getContent(), etc.
Code: Select all
class Page {
private $ID;
private $title;
private $content;
public function __construct($ID) {
// set ID
// query database to get the row etc.
}
public function getTitle() {
return isset($title) ? $title : false;
}
public function getContent() {
return isset($content) ? $content : false;
}
}
Code: Select all
// surely can't be right?
$page = array();
$page_numbers = array(1,2,3,4,5);
foreach ($page_number as $p) {
$page[] = new Page($p);
}
I can provide more info on request, just really wanting OOP to click.
Thanks in advance!