hi guys

i have a condition like this

if(something) {
    $content = "something";
} else {
    $content = "another thing";
}

open_middle_table($content);

this open_middle_table function makes a table and puts the value of the $content in it

no i may have something like this in my script

$content = "<table>"
          ."<tr>"
          ."<td></td>"
          ."<td></td>"
          ."<td></td>"
          ."</tr>"
          ."<table>";

so instead of all this messing up i just thought if i could make it like this

<?php

$content = "

?>

<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<table>


<?php

";

echo $content;

?>

but it doesnt work - it gives me parse error

i am stupid enough to do such a thing cuz i read somewhere that we can effortlessly escape from php into html anytime - its only my imagination though

so what i am asking is if there is anyother way in which i can put a entire table of pure html into $content without going thru the hassles of escaping " and other special chars

thanks anyway

    hi igel

    tell me one more thing ok

    what if i have a condition to check within the table for one particular row

    for example

    
    $mystring = <<<M
    <table>
    <tr>
    <td></td>
    <td></td>
    
    <?php
    
    if($condition) {
    
    <td></td>
    
    }
    
    ?>
    
    <td></td>
    </tr>
    </table>
    M;
    
    

    i know this is not possible but how to do it the right way

    how can a concatenate a heredoc sting in between

    thanks

      AFAIK, you can't concatenate heredoc, but you can insert a variable in it:

      if($condition)
         $line = '<td></td>'; // it may be a heredoc, too.
      
      $mystring = <<<M
      <table>
      <tr>
      <td></td>
      <td></td>
      $line
      <td></td>
      </tr>
      </table>
      M;
      
        Write a Reply...