无法使用php变量设置html表格高度和宽度

无法使用php变量设置html表格高度和宽度,php,html,Php,Html,我正在处理下面的PHP脚本,我想通过使用PHP变量设置td高度和列,我不知道该怎么做。非常感谢任何帮助我解决问题的建议和帮助。谢谢 <?php $n = 5; $table_height = 100; ?> <!DOCTYPE html> <html> <head> <title>Your Table is Ready</title> </head> <body

我正在处理下面的PHP脚本,我想通过使用PHP变量设置td高度和列,我不知道该怎么做。非常感谢任何帮助我解决问题的建议和帮助。谢谢

<?php

$n = 5;
$table_height = 100;

?>

<!DOCTYPE html>
<html>
    <head>
        <title>Your Table is Ready</title>
    </head>
    <body>
         <table>
            <?php for ($i = 0; $i < $n; $i++): ?>
            <tr>
                <?php for ($x = 0; $x < $n; $x++): ?>
                <td height="{$table_height}"; width = "{$n}"><?php print($i * $x) ?></td> 
                <?php endfor ?>   
                </tr>
            <?php endfor ?>
        </table>
    </body>
</html>

你的桌子准备好了
更改

<td height="{$table_height}";...>


以回音。

首先,变量不在PHP块中。另一方面,使用样式属性要比使用
height
width
更好,尽管它可能没有您期望的那么有效。
<td height="<?= $table_height ?>px";...>