Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top