visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: defined string in here document


By: VB guy Canada  Date: 16/07/2003 00:00:00  English  Points: 100 Status: Answered
Quality : Excellent
I need to do something like the code below. I realize that what I have won't work, it's just to give an idea of what i need.

I need to use the here document with defined strings. Is something like this possible?


echo <<<BLOCK6
<FONT size="-1">
Activity type<FONT size="1" color="#CC0000"><b>*</b>&nbsp;&nbsp;</FONT> <SELECT name="activitytype">
<OPTION>choose</OPTION><? echo ACTIVITYTYPES; ?>
</SELECT> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Area<FONT size="1" color="#CC0000"><b>*</b>&nbsp;&nbsp;</FONT> <SELECT name="area">
<OPTION>choose</OPTION><? echo AREAS; ?>
</SELECT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Age range<FONT size="1" color="#CC0000"><b>*</b>&nbsp;&nbsp;</FONT> <SELECT name="agefrom">
<OPTION>from</OPTION><? echo AGES; ?>
</SELECT> <FONT size="5"><b>-</b></FONT> <SELECT name="ageto">
<OPTION>to</OPTION><? echo AGES; ?>
</SELECT> yrs.<p>

BLOCK6;



By: VGR Date: 16/07/2003 21:48:00 English  Type : Answer
not with defines, sorry. But it's the best way to use variables...


By: waygood Date: 16/07/2003 22:42:00 English  Type : Comment
If you are going to use this pieces of code in several locations, you could keep the snippits in seperate files and just include them when needed.

$ages=4;
include('block6.php');

Or keep them in one file and select the one you want to include (see $block=6)

$ages=4;
$area="this area!";
$activitytype="bob"
$block=6;
include('block_code.php');

----block_code.php-------
switch($block)
{
case "6":
echo --your code here--
break;
}



I dont recommend using this as a function as you would need to make the variables global, or pass them as parameters to the function. Which I think is going to be difficult for you to cope with at this stage.

function show_block_code($block)
{
switch($block)
{
case "6":
echo --your code here--
break;
}

}

Do register to be able to answer

EContact
browser fav
page generated in 332.811830 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page