Php 是否在表中打印函数值?
如何在表中打印函数的值?我很难找到答案,在谷歌上查了一下,看了一些Youtube PHP教程,但还是一无所获,还有一个错误告诉我$cols、$rows、$rNumber未定义。输出应该看起来像一个半金字塔Php 是否在表中打印函数值?,php,function,html-table,Php,Function,Html Table,如何在表中打印函数的值?我很难找到答案,在谷歌上查了一下,看了一些Youtube PHP教程,但还是一无所获,还有一个错误告诉我$cols、$rows、$rNumber未定义。输出应该看起来像一个半金字塔 <?php do { $rNumber = mt_rand(3, 11); } while ($rNumber % 2 == 0); echo '<strong>Looping Statements Exercises</strong>'; echo '
<?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>';
您的功能:
function figure_b($rows, $cols)
{
if($rNumber == 5)
{
for($rows = 0; $rows<=5; $rows++)
{
for ($cols = 0; $cols<=5; $cols++)
{
return $cols;
}
return $rows;
}
}
}
函数图b($rows,$cols)
{
如果($rNumber==5)
{
对于($rows=0;$rows您可以从尝试更改此
$rNumber = mt_rand(3,11);
}while ($rNumber % 2 == 0);
为此:
$rNumber = mt_rand(3,11);
while ($rNumber % 2 == 0);
你的职能是:
function figure_b($rNumber)
{
if($rNumber == 5)
{
for($rows = 0; $rows<=5; $rows++)
{
for ($cols = 0; $cols<=5; $cols++)
{
echo $cols;
}
echo $rows;
}
}
}
函数图b($rNumber)
{
如果($rNumber==5)
{
对于($rows=0;$rowsfigure_b($cols,$rows),变量在哪里?这并没有导致错误,但也许您应该关闭标记。。。
$rNumber = mt_rand(3,11);
while ($rNumber % 2 == 0);
function figure_b($rNumber)
{
if($rNumber == 5)
{
for($rows = 0; $rows<=5; $rows++)
{
for ($cols = 0; $cols<=5; $cols++)
{
echo $cols;
}
echo $rows;
}
}
}