I'm missing a fundamental concept. The symptom is, despite using __toString, I still get "object #2" when I echo $signIn.

I apologize for the amount of code included here, but I don't know where to focus.

I have a factory pattern that decides which GUI I want:
switch ($pageId) {
case ("sign in"):
switch ($action) {
$signIn = new offbook_cls_SignInForm();
$condition = $signIn->FormOnly();
$this->SetNext($condition, "Sign In", "retrieve", "Sign In", "default");
echo $signIn;
case ("register"):
offbook_cls_SignInForm extends an abstract offbook_cls_Presentation which contains, among others, one __toString and two abstract methods.
abstract class offbook_cls_Presentation{
protected $docType; // Object containing <!DOCTYPE clause
protected $openHTML; // object containing <html... clause
protected $header; // object containing <head>...</head> (delegated)
protected $body; // object containing <body>...</body> (delegated)
protected $closeHTML; // object containing </html>
abstract function SetHeader(); //delegates to offbook_cls_Heading object
public function GetHeader() {
return $this->header;

abstract function SetBody(); //delegates to offbook_cls_Body child
public function GetBody() {
return $this->body;
public function _toString(){
$html = GetDocType() . "\n";
$html .= GetOpenHTML() . "\n";
$html .= GetHeader() . "\n";
$html .= GetBody() . "\n";
$html .= GetCloseHTML() . "\n";
return $html;
Here's offbook_cls_SignInForm (initiated from the factory)
class offbook_cls_SignInForm
extends offbook_cls_Presentation {

public function SetHeader(){
$head = new offbook_cls_Heading("Sign In Form");
$head->SetStyle("index.css", "text/css"); // add custom style sheet
return $head;

public function SetBody(){
return "<p>SignIn Body</p>";

public function PopulateForm(){
echo "Populate Form";
return $true;

public function FormOnly(){
$heading = $this->SetHeader(); // populate parent
$body = $this->SetBody(); // populate parent
return true;
and finally, an excerpt from offbook_cls_heading
Class offbook_cls_Heading{
function SetStyle($url_p, $type_p) {
// e.g. SetStyle("base.css", "text/css"
$this->styles[$url_p] = $type_p; // types can be the same, URLs aren't
function __toString() {
$html = "<head>";
$html .= " <title>'$this->title'</title>\n";
foreach($this->styles as $url=>$type) {
$html .= " <link rel=\"stylesheet\" type=\"'$type'\" href=\"offbook/'$url'\" />\n";
foreach($this->scripts as $url=>$type) {
$html .= " <script type=\"'$type'\" src=\"'$url'\"> </script>\n";
$html .="</head>\n";
return $html;
Again what I get is "object #2" when I echo $signIn.