Blogger Information
Blog 67
fans 0
comment 2
visits 72018
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP运算符、赋值运算符、动态表格
搁浅
Original
906 people have browsed it

运算符

  1. // + - *(×) /(÷) %(取模,取除不尽的余数)
  2. $a=10;
  3. $b=4;
  4. echo $a+$b; //14
  5. echo $a-$b; //6
  6. echo $a*$b; //40
  7. echo $a/$b; //2.5
  8. echo $a%$b; //2

赋值运算符

  1. echo $a+=$b; //14
  2. echo $a-=$b; //6
  3. echo $a*=$b; //40
  4. echo $a/=$b; //2.5
  5. echo $a%=$b; //2
  6. $c='大家';
  7. echo $c[0],$c[1],$c[2]; //大

字符串函数使用示例

  1. $d='<div>a123a';
  2. trim($d); //去除字符串首尾处的空白字符(或者其他字符,比如html标签)
  3. is_numeric($d); //判断是否是数字类型
  4. is_int($d); //判断是否是int整数类型

动态表格

  1. function tab($ar,$he,$width,$height){
  2. $table='<table border="1" cellspacing="0">';//第一个变量不使用.链接符
  3. $table.='<thead>';
  4. $table.='<tr>';
  5. foreach ($he as $k => $v) {
  6. $table.='<th width="'.$width.'" height="'.$height.'">'.$v.'</th>';
  7. }
  8. $table.='</tr>';
  9. $table.='</thead>';
  10. $table.='<tbody align="center">';
  11. foreach ($ar as $k2 => $v2) {
  12. $table.='<tr>';
  13. foreach ($v2 as $k3 => $v3) {
  14. $table.='<td>'.$v3.'</td>';
  15. }
  16. $table.='</tr>';
  17. }
  18. $table.='</tbody>';
  19. $table.='</table>';
  20. return $table;
  21. }
  22. echo tab($arr,$head,100,200);
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post