tags:

views:

241

answers:

1

I'm trying to heredoc the following code:

<?php 
   //some php
   //some more php
   if (some condition) {
?>   
   <label>CMKS1<?php echo $CMKS1_CMKS2_space; ?>CMKS2</label>
   <input name="cmks1" type="text" class="base-cls <?php if ($err1) echo "err-cls"; ?>" />
   <input name="cmks2" type="text" class="base-cls <?php if ($err2) echo "err-cls"; ?>" />    
<?php
   }//if
   //some final php here
?>

but I'm stuck on the $CMKS1_CMKS2_space variable on the label line and the 2 if conditional statements in input name cmks1 and cmks2. Is the heredoc format able to handle these gracefully? For example the label line in heredoc would look like this:

<label>CMKS1$CMKS1_CMKS2_spaceCMKS2</label>

or should I enforce an extra discretionary space:

<label>CMKS1 $CMKS1_CMKS2_space CMKS2</label>

As for the if conditional statements on the 2 input lines, I'm not even sure how to port these...

TIA

+1  A: 

Inside the heredoc, you can use this syntax to specify the correct variable names:

<label>CMKS1{$CMKS1_CMKS2_space}CMKS2</label>

Unfortunately, there is no way to add the conditional statements inside heredoc syntax.

too much php
Was hoping to port the ifs too, but thanks for saving my time searching
Chris
Since you are using the same CSS class ('err-cls') for both inputs, you may as well just put that in a $variable above your heredoc.
too much php