如何在表格中打印函數的值?我很難弄清楚這一點,在Google中查看它,觀看一些Youtube PHP教程,但仍然沒有任何結果,還有一個錯誤,告訴我$ cols,$ rows,$ rNumber未定義。輸出應該看起來像一個半金字塔。在表格中打印函數值?
<?php
do {
$rNumber = mt_rand(3, 11);
} while ($rNumber % 2 == 0);
echo '<strong>Looping Statements Exercises</strong>';
echo '<br>';
echo '<br>';
echo 'This page shows eight (8) figures programatically generated by looping statements. Number of rows are random odd integer between 3 and 11.';
echo '<br>';
echo '<br>';
echo '<table border = "1">';
echo '<tr>';
echo '<td colspan = "4"><center>Size:<strong>', $rNumber, ' x ', $rNumber, '</strong>';
echo '</tr>';
echo '<tr>';
echo '<td> Figure A';
echo '<td> Figure B';
echo '<td> Figure C';
echo '<td> Figure D';
echo '</tr>';
echo '<tr>';
echo '<td> Figure A here';
echo '<td>', figure_b($cols, $rows), '</td>';
echo '<td> Figure C here';
echo '<td> Figure D here';
echo '</tr>';
echo '<tr>';
echo '<td> Figure E';
echo '<td> Figure F';
echo '<td> Figure G';
echo '<td> Figure H';
echo '</tr>';
echo '<tr>';
echo '<td> Figure E here';
echo '<td> Figure F here';
echo '<td> Figure G here';
echo '<td> Figure H here';
echo '</tr>';
function figure_b($rows, $cols)
{
if ($rNumber == 5) {
for ($rows = 0; $rows <= 5; $rows++) {
for ($cols = 0; $cols <= 5; $cols++) {
return $cols;
}
return $rows;
}
}
}
echo '</table>';
figure_b($的cols,$行)在哪裏那個變量? –
這不是導致錯誤,但也許你應該關閉標籤... – lpg