Re: Oputting Forms Within a Class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Terça 10 Abril 2007 14:49, CK escreveu:
> 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(){
> <!--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?

You can have a look at echo docs [1]. You'll found intersting things there... 
=]

What about:

 private function buildInt(){
echo <<<MY_FORM
 <!--Script 10.1- calculator.php-->

 <form action="calculator.php" method="post">
 	//Form elements omitted for brevity....

 </form>
MY_FORM;
   }


Enjoy!! =]



[1] - http://www.php.net/manual/en/function.echo.php


-- 
Davi Vidal
davividal@xxxxxxxxxxxxxxxx
davividal@xxxxxxxxx
--

Agora com fortune:
"NOTICE:

-- THE ELEVATORS WILL BE OUT OF ORDER TODAY --

(The nearest working elevator is in the building across the street.)"

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux