LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Question about output for php (https://www.linuxquestions.org/questions/programming-9/question-about-output-for-php-424519/)

Hockeyfan 03-13-2006 04:14 PM

Question about output for php
 
I am creating a form dynamically and I've seen a method of outputing the form that I am not familiar with. I have seen a form be produced on the fly by putting the entire contents in a variable named $form. The form is displayed without any echo statement. I have searched the php manual and I couldn't find anything that explains it. If anyone knows would they plase take the time and explain it to me.

Thanks,

Hockeyfan

zeitounator 03-14-2006 09:30 AM

Any example code ?

My guess is that your $form variable holds some kind of form object which as a method to output its content... something like

Code:

$form = new FormObject;
$form->setAction('/some/url');
$form->addField('text', 'name');
$form->render();

But in any case, the content of the form must be printed to the output with an 'echo' or 'print' statement (in the example above, that would happen somewhere in the render() method of the form object.

The only other thing I can think of is that you have seen the use of some sort of 'echo/print' shortcut in an html template. Something like

Code:

[some html]
<?php
$form = '<form action"....................">all the content</form>';
?>
[some more html]
<?=$form?> <= this is a shortcut to <?php echo $form ?>



All times are GMT -5. The time now is 11:21 AM.