It's giving me unexpected $end but I can't find where is the problem, there's no spaces or indentation before or after EOD. I'm using eval() to do the replacing.
<?php echo <<<EOD
<?php
if((\${$type}s = \$this->{$type}())):
foreach(\${$type}s as \$item):
?>
<tr>
<td><?php echo \$item->Name; ?></td>
<td><?php echo Table::countRows(\$item->Name); ?></td>
<td><?php echo \$item->Engine; ?></td>
<td><a href="<?php echo get_url('cp/system/database/tables/view/'.\$item->Name); ?>">Show</a></td>
<td><a href="<?php echo get_url('cp/system/database/tables/rename/'.\$item->Name); ?>">Rename</a></td>
<td><a href="<?php echo get_url('cp/system/database/tables/delete/'.\$item->Name.'/confirm'); ?>" class="item-remove-button">Delete</a></td>
</tr>
<?php
endforeach;
endif;
?>
EOD; ?>