php 函数学习

注意
本文最后更新于 2023-12-08,文中内容可能已过时。

练习 php 函数的基本使用。
注:
必选参数在可选参数的前面。
可在函数中定义函数,需要先调用外层函数才能调用内层函数。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?php
/*
创建表格
*/
function createTable($rows,$cols,$bgcolor='pink',$content='x'){
  $table = "<table border='1' bgcolor='{$bgcolor}' cellpadding='10' cellspacing='0' width='50%' >";
  for($i=1;$i<=$rows;$i++){
    $table.="<tr>";
    for($j=1;$j<=$cols;$j++){
      $table.="<td>{$content}</td>";
    }
    $table .="</tr>";
  }
  $table.="</table>";
  return $table;
}
echo createTable(5,5,'pink','hello lruihao');
?>

php 创建表格

相关内容

Buy me a coffee~
Lruihao 支付宝支付宝
Lruihao 微信微信
0%