Connecting Tech Pros Worldwide Help | Site Map

Dilema, Blocks of HTML within PHP

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 11:29 AM
beezmnet@gmail.com
Guest
 
Posts: n/a
Default Dilema, Blocks of HTML within PHP

Well...

I need to be able to have a large block of HTML code inside a PHP
document, assign it a variable, and use other variables, functions, and
objects within the HTML code still.

Clarification:

I have the following code (as an example):

$variable = <<<HTML
<table>
<tr><td>$text</td></tr>
<tr><td>echo $config->getBlah()</td></tr>
</table>
HTML;

I need to be able to do that ^, that actual code wouldn't work, but it
is an example of what I need to do. I have tried searching for the <<<
operator, or whatever it is, the problem is most search utilities won't
recognize <<<, so it is really really hard to search and find answers
about it, I can't find anything about it on the php manual, I'm falling
onto a last resort by posting on some forums to see if anyong is able
to help me.

So question being really:
Is there a way I can split that so it recognizes those lines as PHP and
not part of the block of HTML code
OR
Is there another method that I can use to achieve this same effect ?

I have to be able to keep the block of code together, not seperating
each line into a variable declaration. such as:
$var = "<tr><td>" . $text . "</td></tr>";
$var .= "<tr><td>" . echo $config->getBlah(); . "</td></tr>";
Do NOT want to do that.

So if anyone has any ideas/solutions, please, please let me know :)

Thanks.


  #2  
Old July 17th, 2005, 11:29 AM
beezmnet@gmail.com
Guest
 
Posts: n/a
Default Re: Dilema, Blocks of HTML within PHP

For anyone else that may be interested, I was able to get an answer to
my question.
Here would be the syntax of what I need to do:

$variable =<<<HTML
<table>
<tr><td>{$text}</td></tr>
<tr><td>{$config->getBlah()}</td></tr>
</table>
HTML;

  #3  
Old July 17th, 2005, 11:29 AM
chernyshevsky@hotmail.com
Guest
 
Posts: n/a
Default Re: Dilema, Blocks of HTML within PHP

The ability to insert code into HTML is the raison d'etre of PHP.

<table>
<tr><td><?=$text?></td></tr>
<tr><td><?=$config->getBlah()?></td></tr>
</table>

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.