Entry
What is the syntax for a really long variable, in this case a whole form?
Sep 28th, 2001 06:17
Philip Olson, k tombeau,
Many different routes can be taken all of which depends on your goals.
a) Use an include
Put the form in a seperate file and when needed, make a call to it.
Something like :
if (empty($form_submitted)) {
include 'form.php';
}
b) Use a function
HTML works great in functions, something like :
<?php
function myForm() {
?>
<form action="process.php" type="POST">
<input type="text" name="foo[name]">
<input type="text" name="foo[email]">
<input type="submit" name="submit">
<input type="hidden" name="form_submitted" value="1">
</form>
<?php
}
?>
Now calling that function will produce the form.
c) Use heredoc syntax
HEREDOC can be demonstrated at the following location :
http://www.php.net/manual/en/language.types.string.php
Essentially it looks like this :
$form = <<<MYFORM
<form>
<input ...>
</form>
MYFORM;