I am a bit rusted in PHP and currently struggling to do something that should be quite simple.
$value = "PUPPY";
$html .= '<td>{$value}</td>';
echo $html; // Doesn't work, prints {$value}.... Should be... PUPPY
I know there's a simple way for doing this but i just forgot and cannot find a definitive method on Google or StackOverflow.
I need to place the html in a variable cause once it is all done, it gets used by tcpdf::writeHtml()
I already tried :
$html .= "<td align='right' nowrap>".$value."</td>";
echo $html; // But this outputs a TD tag with attribute nowrap="" and this is not valid HTML... tcpdf:writeHtml rejects this.
UPDATE: The bug was in fact caused by a bad usage of the "nowrap" attribute deprecated some time ago.
Single quoted strings are not interpolated in php. Use double quotes instead.
$value = "PUPPY";
$html .= "<td>{$value}</td>";
echo $html;
$value = "PUPPY";
$html .= "<td>{$value}</td>";
echo $html;
Use " instead of '
Take a look at the documentation about Strings on PHP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With