HTML/Page.php - multiple objects in body var

From: Date: Tue, 12 Feb 2002 21:38:07 +0000
Subject: HTML/Page.php - multiple objects in body var
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-4658@lists.php.net to get a copy of this message
Hello! I've done a small adjustment to the HTML/Page.php class, that I want to share with you. Today the toHtml function only supports one object in the body var: [...] if (is_object($this->body)) { if (method_exists($this->body, "toHtml")) { $strHtml .= $this->body->toHtml(); } elseif (method_exists($contents, "toString")) { $strHtml .= $contents->toString(); } } else { $strHtml .= $this->body; } [...] I wrote a simple elseif to check if $this->body is an array instead: [...] if (is_object($this->body)) { if (method_exists($this->body, "toHtml")) { $strHtml .= $this->body->toHtml(); } elseif (method_exists($contents, "toString")) { $strHtml .= $contents->toString(); } } elseif(is_array($this->body)) { foreach($this->body as $element) { if(is_object($element)) { if (method_exists($element, "toHtml")) { $strHtml .= $element->toHtml(); } elseif (method_exists($element, "toString")) { $strHtml .= $element->toString(); } } else { $strHtml .= $element; } } } else { $strHtml .= $this->body; } [...] I guess you catch the point. I've attached the complete file. There might be some other adjustments there, but just ignore them. I've also made a div (layer) class, if it might interest you. Thank you for making this great source available for the world. Regards, Nils-Fredrik

« previous php.pear.dev (#4658) next »