0

$html = '// html code' is used to add html code in TCPDF. How can I add a if else statement between the quote? I added a variable by adding ' . $code . '

$html = '<td>
            if (' . get_prop($this->iform, 'temp') . ' == 0) {
                <input type="checkbox" name="temp" value="temp" readonly="true" />
            } else {
                <input type="checkbox" name="temp" value="temp" readonly="true" checked="checked" />
            }
         </td>'
Noobs
  • 47
  • 6

1 Answers1

1

How about using the ternary ?: operator

$html = '<td>'
            . ((get_prop($this->iform, 'temp') . ' == 0) ?
                '<input type="checkbox" name="temp" value="temp" readonly="true" />'
            :
                '<input type="checkbox" name="temp" value="temp" readonly="true" checked="checked" />')
         . '</td>'
memo
  • 1,868
  • 11
  • 19