php-general Digest 1 Jul 2012 23:22:34 -0000 Issue 7873
Topics (messages 318356 through 318358):
Re: embedding php inside of php
318356 by: Tim Streater
318357 by: Yared Hufkens
Hello again
318358 by: RGraph.net support
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 01 Jul 2012 at 01:00, Tim Dunphy <bluethu...@gmail.com> 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
--- End Message ---
--- Begin Message ---
If you are using PHP 5.4 or short_open_tag is 1, you can also do this:
Some HTML text here<?=subject?>some more HTML text<?=$text?>and finally other
stuff here
Am 01.07.2012 14:01, schrieb Tim Streater:
> On 01 Jul 2012 at 01:00, Tim Dunphy <bluethu...@gmail.com> 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
>
>
>
--- End Message ---
--- Begin Message ---
Hi,
Just thought I'd say hello again. Back to brush up on my PHP a little
after a bit of a break - more reading than replying I'd imagine. I
have some pretty bad jokes too that I might surreptitiously insert
here and there...
Cheers.
--
Richard Heyes, RGraph.net support
RGraph: JavaScript charts for your website
http://www.rgraph.net
--- End Message ---