Re: Oputting Forms Within a Class

From: Date: Tue, 10 Apr 2007 17:57:58 +0000
Subject: Re: Oputting Forms Within a Class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-252445@lists.php.net to get a copy of this message
CK wrote:
Hi All, Experimenting with OOP PHP,please be gentle. Attempting to output a form within a class: From calculator.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Calculator OOP PHP</title> </head> <body> <?php include "class.calculator.php"; ?> </body> </html> From class.calculator.php: <?php class Calculator{ //variable declaration //constuctor function function __construct(){//calls all methods
    $this->buildInt();
} private function buildInt(){ You should probably use the echo function to output the HTML...
i.e. echo "<!-- Script 10.1 - calculator.php--><br/>\n"; ...
<!--Script 10.1- calculator.php--> <form action="calculator.php" method="post">
    //Form elements omitted for brevity....
    </form>
} } ?> This is returned to the browser: "Parse error: syntax error, unexpected '<' in /Users/chris/Sites/php/oop/class.calculator.php on line 20" What concept did I miss, if some online reference is available please pass along? --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#252445) next »