Iain Simpson
Iain Simpson

Reputation: 469

Define an array wrapped in styling

Is it possible to wrap a value in HTML like the following example?

$email_message = ('somehtml', $emailtext, 'somemorehtml');

So that when it is run you get:

<html>
    <head>
         <style>body {color:#eee;}</style>
    </head>
    <body>
        <p>Hello and welcome to our website</p>
    </body>
</html>

Upvotes: 0

Views: 46

Answers (3)

jere
jere

Reputation: 4304

it's possible but it's not the best practice. it would be better to do:

<html>
<head><style>body {color:#eee;}</style></head>
<body>
<p>Hello and welcome to our website, Mr <?php echo $name; ?></p>
</body>
</html>

do you absolutely need to echo your html?

Upvotes: 0

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114367

You're looking for a templating system.

jQuery Templating - for doing it on the client

PHP TAL - for doing it with PHP on the server

Upvotes: 1

Ashley Banks
Ashley Banks

Reputation: 528

$msg = 'Hello and welcome to our website';
$body = '<html>
         <head><style>body {color:#eee;}</style></head>
         <body>
         <p>' . $msg . '</p>
         </body
         </html>';

 echo $body;

?

Upvotes: 3

Related Questions