search

Home  >  Q&A  >  body text

请教下老师,PHP函数之自定义函数的课后作业的代码如何编写

根据前面的学习,我对这章课后作业的理解可能还不深入,希望得到老师的帮助。

<?php

function xh($l,$c=blue){//$l控制偶数行的颜色,$c控制奇数行的颜色

echo '<table width="800" border="1">';

$i = 1;

while($i < 11){

if($i % 2 == 1){

echo "<tr bgcolor='$c'>";

}else{

echo "<tr bgcolor='$l'>";

}

$j = 1;

while($j < 11){

echo '<td>'.$j.'</td>';

$j++;

}

$i++;

echo '</tr>';

}

echo '</table>';

return;

}

xh(green);

?>


<?php 	echo 'I\'m a green hand'; ?><?php echo 'I\'m a green hand'; ?>2863 days ago2328

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:32:42

    Ask the teacher, how to write the code for the after-school homework of the custom function of the PHP function - PHP Chinese website Q&A - Ask the teacher, how to write the code for the after-school homework of the PHP function's custom function - PHP Chinese website Q&A

    Let’s watch and learn.

    reply
    0
  • 代言

    代言2017-02-24 16:06:45

    看了下代码,能实现课后作业的要求,只是有两个报错,把$c=blue和xh(green)改一下,加个双引号就可以了。

    $c="blue"   xh("green")

    reply
    2
  • Cancelreply