Languages :: PHP :: defined string in here document |
|||
| By: VB guy |
Date: 16/07/2003 00:00:00 |
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> </FONT> <SELECT name="activitytype"> <OPTION>choose</OPTION><? echo ACTIVITYTYPES; ?> </SELECT> Area<FONT size="1" color="#CC0000"><b>*</b> </FONT> <SELECT name="area"> <OPTION>choose</OPTION><? echo AREAS; ?> </SELECT> Age range<FONT size="1" color="#CC0000"><b>*</b> </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 | Type : Answer |
|
| not with defines, sorry. But it's the best way to use variables... |
|||
| By: waygood | Date: 16/07/2003 22:42:00 | 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 |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








