On 01 Jul 2012 at 01:00, Tim Dunphy <bluethundr@xxxxxxxxx> wrote: > I am trying to get the hang of php using some examples that I found > in a book. I've been making progress lately, but one thing has me a > bit stumped. > > In an HTML form that I am echoing through PHP I would like to embed > smaller chunks of php in the code like so: > > > echo '<br /><br /> > <form method="post" action="sendemail.php"> > <label for="subject">Subject of email:</label><br /> > <input id="subject" name="subject" type="text" value="<?php > echo $subject;?>"><br /> > <label for="elvismail">Body of email:</label><br /> > <textarea id="elvismail" name="elvismail" rows="8" > cols="40">"<?php echo $text;?>" </textarea><br /> > <input type="submit" name="Submit" value="Submit" /> > </form>'; You don't need the nested echoes. Just concatenate instead: echo '<br /><br /> <form method="post" action="sendemail.php"> <label for="subject">Subject of email:</label><br /> <input id="subject" name="subject" type="text" value="' . $subject . '"><br /> <label for="elvismail">Body of email:</label><br /> <textarea id="elvismail" name="elvismail" rows="8" cols="40">"' . $text . '" </textarea><br /> <input type="submit" name="Submit" value="Submit" /> </form>'; In short you're doing this : echo 'Some HTML text here ' . $subject . ' some more HTML text ' . $text . ' and finally other stuff here'; -- Cheers -- Tim
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php