\n\n"; $this->DisplayTitle(); $this->DisplayStyling(); $this->DisplayScript(); echo ""; $this->DisplayHeading(); if ($thingidea == "" && $idea == "") { $this->DisplayAuthor(); } else { $this->DisplayThing($thingidea, $idea); } $this->DisplayPublishDate(); } public function Footer($prefix = "") { echo $prefix . ""; } public function DisplayTitle() { echo "" . $this->title . ""; } public function DisplayExternalStyling() { echo ""; } public function DisplayStyling() { $this->DisplayExternalStyling(); echo ""; } public function DisplayScript() { echo ""; } public function DisplayHeading() { echo "

Title: " . $this->title . "

"; } public function DisplayAuthor() { echo "

Author: " . $this->author . "

"; } public function __call($method, $parr) { $retval = ""; if ($method == "DateTimeDisplay") { if ($parr[0][1] == "") { $retval .= str_replace("-", " ", str_replace(":", " ", $parr[0][0])); } else if (is_numeric($parr[0][1])) { $months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; if (sizeof($parr[0]) == 2) { $retval .= $months[$parr[0][1] - 1] . " " . $parr[0][0]; } else if (is_numeric($parr[0][0])) { if (strlen($parr[0][0]) > strlen($parr[0][2]) || $parr[0][0] > 31) { $retval .= $parr[0][2] . " " . $months[$parr[0][1] - 1]; $parr[0][2] = $parr[0][0]; for ($i=2; $i strlen($parr[0][2]) || $parr[0][0] > 31) { $retval .= $parr[0][2] . " " . $parr[0][1]; $parr[0][2] = $parr[0][0]; for ($i=2; $ipublish_date)); if (sizeof($dfields) == 1) $dfields = [$this->publish_date, ""]; $tfields = []; if (sizeof($dfields) >= 3) { $tfields = explode(":", $dfields[sizeof($dfields) - 1]); if (sizeof($tfields) == 1 && $tfields[0] == $dfields[sizeof($dfields) - 1]) $tfields = []; } echo "

Published On: " . $this->DateTimeDisplay(array_merge($dfields, $tfields)); } public function DisplayThing($nameofthing, $thing) { $hthing = "4"; if ($nameofthing == "Author") $hthing = "2"; if ($nameofthing == "Publisher") $hthing = "2"; if ($nameofthing == "Title") $hthing = "1"; if (strpos($nameofthing, "Date") !== false || strpos($nameofthing, "Published On") !== false || strpos($nameofthing, " On") !== false) { $hthing = "3"; $this->DisplayPublishDate(); } else { echo "" . $nameofthing . ": " . $thing . ""; } } } class book extends publication { public $title; public $author; public $publish_date; function __construct($indata1, $indata2, $indata3) { $this->title = $indata1; $this->author = $indata2; $this->publish_date = $indata3; } function __destruct() { } function __get($name) { return $this->$name; } function __set($name, $value) { $this->$name = $value; } public function Display() { $this->NonFooter(); $this->Footer(); } } class magazine extends publication { public $title; public $publisher; public $publish_date; function __construct($indata1, $indata2, $indata3) { $this->title = $indata1; $this->publisher = $indata2; $this->publish_date = $indata3; } function __destruct() { } function __get($name) { return $this->$name; } function __set($name, $value) { $this->$name = $value; } public function Display() { $this->NonFooter("Publisher", $mymagazine->publisher); $this->Footer(); } } // Program execution starts here ... $myformstring = ""; $mybook = new book("To Kill A Mockingbird", "Harper Lee", "1960-07-11"); $mymagazine = new magazine("Cosmopolitan", "Schlicht & Field", "1886"); if (1 == 1) { $mymagazine->NonFooter("Publisher", $mymagazine->publisher); $concepts = ["Title", "Author", "Publish Date"]; $j = 0; foreach ($mybook as $attrib) { $mybook->DisplayThing($concepts[$j], $attrib); $j++; } } else { $mybook->NonFooter(); $concepts = ["Title", "Publisher", "Publish Date"]; $j = 0; foreach ($mymagazine as $attrib) { $mymagazine->DisplayThing($concepts[$j], $attrib); $j++; } } if (isset($_GET['publisher'])) { $mymagazine = new magazine($_GET['title'], $_GET['publisher'], $_GET['publish_date']); $concepts = ["Title", "Publisher", "Publish Date"]; $j = 0; foreach ($mymagazine as $attrib) { $mymagazine->DisplayThing($concepts[$j], $attrib); $j++; } } else if (isset($_POST['publisher'])) { $mymagazine = new magazine($_POST['title'], $_POST['publisher'], $_POST['publish_date']); $concepts = ["Title", "Publisher", "Publish Date"]; $j = 0; foreach ($mymagazine as $attrib) { $mymagazine->DisplayThing($concepts[$j], $attrib); $j++; } } else if (isset($_GET['author'])) { $mybook = new book($_GET['title'], $_GET['author'], $_GET['publish_date']); $concepts = ["Title", "Author", "Publish Date"]; $j = 0; foreach ($mybook as $attrib) { $mybook->DisplayThing($concepts[$j], $attrib); $j++; } } else if (isset($_POST['author'])) { $mybook = new book($_POST['title'], $_POST['author'], $_POST['publish_date']); $concepts = ["Title", "Author", "Publish Date"]; $j = 0; foreach ($mybook as $attrib) { $mybook->DisplayThing($concepts[$j], $attrib); $j++; } } // Create a form for optional interaction ... $myformstring = "
Your BookYour Magazine
"; $myformstring .= "
Title:

Author:

Published On:
"; $myformstring .= "
"; $myformstring .= "
Title:

Publisher:

Published On:
"; $myformstring .= "
"; $mypublication = clone $mybook; $mypublication->Footer($myformstring); ?>