Blogger Information
Blog 21
fans 0
comment 0
visits 20139
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP与HTML混编
电动机的博客
Original
1186 people have browsed it

总结


条件:if ()else的应用、三元运算符:  ?  :    条件? 真运行:假运行;

比较符 :>、<、>=、<=、==(值相等)、===(类型与值同时相等)、<>、==!;

联结符:.=、.;

自定义函数 function  name(){}按命名可以分为有名字的函数 与没名字的函数,按传参数的个数可以单参与多参函数;


 实例

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
	<title><?php echo '员工管理系统'; ?></title>
	<style type="text/css">
		table,th,td{
			border: 1px solid #666;
			padding: 8px;
		}
		table{
			border-collapse: collapse; /*去掉边框*/
			width: 80%;
			text-align: center;
			margin: 30px auto;
		}
		thead tr:first-of-type {
			background-color: lightblue;
			}
		tbody tr:hover{
			background-color: #efefef; 
			}		}
		table>caption{
			background-color: #ccc;
			font-size: 50px;
			margin-bottom: 1px;
		}
		table+ p{
			text-align: center;
		}
	</style>
</head>
<body>
 <table>
 	<caption><h2><?php echo '员工信息表'; ?></h2></caption>
 	<thead>
 		<tr>
 			<th>编号</th>
 			<th>姓名</th>
 			<th>年龄</th>
 			<th>性别</th>
 			<th>邮箱</th>
 			<th>密码</th>
 		</tr>
 	</thead>
 	<tbody>
 		<tr>
 			<th>1</th>
 			<th>猪哥</th>
 			<th>30</th>
 			<th>男</th>
 			<th>zhug@php.cn</th>
 			<th>123456</th>
 		</tr>
 		<tr>
 			<td>2</td>
 			<td>朱老师</td>
 			<td>40</td>
 			<td>男</td>
 			<td>zls@php.cn</td>
 			<td>123456</td>
 		</tr>
 		<tr>
 			<td>3</td>>
 			<td>西门大官人</td>
 			<td>50</td>
 			<td>男</td>
 			<td>xmdgr@php.cn</td>
 			<td>123456</td>
 		</tr>
 		<tr>
 			<td>4</td>
 			<td>灭绝师太</td>
 			<td>60</td>
 			<td>女</td>
 			<td>mjst@php.cn</td>
 			<td>123456</td>
 		</tr>
 		<tr>
 			<td>5</td>
 			<td>韦小宝</td>
 			<td>20</td>
 			<td>男</td>
 			<td>wxb@php.cn</td>
 			<td>123456</td>
 		</tr>
        <?php
            $arr=array(
                 array(
                     6,
                    '欧阳克',
                     18,
                    '男',
                    'ou@php.cn',
                    '123456'
                        ),
                 array(
                     7,
                    '王蓉',
                     15,
                     '女',
                    'hr@php.cn',
                       '123456'
                       ));
                 
  
 		     foreach($arr as $b){
             ?>
 		     <tr>
 			   <td><?php echo $b[0];?> </td>
 			   <td><?php echo $b[1];?> </td>
 			   <td><?php echo $b[2];?> </td>
 			   <td><?php echo $b[3];?> </td>
 			   <td><?php echo $b[4];?> </td>
 			   <td><?php echo $b[5];?> </td>
 		     </tr>
 	       <?php
 	       
 	         }   
      ?>

      <?php
            $arr=[
            	   ['id'=>8,'name'=>'王***师','age'=>50,'sex'=>'男','email'=>'ou@php.cn','password'=>sha1('123456')],
                   ['id'=>9,'name'=>'梅超风',  'age'=>35,'sex'=>'女','email'=>'hr@php.cn','password'=>sha1('123456')],
               ];
                 
             $date='';
 		     foreach($arr as $c){
             $date.='<tr>';
 			  $date.="<td>$c[id]</td>";
 			   $date.="<td>$c[name]</td>";
 			   $date.="<td>{$c['age']}</td>";
 			   $date.="<td>{$c['sex']}</td>";
 			   $date.="<td>{$c['email']}</td>";
 			   $date.="<td>{$c['password']}</td>";
 		     $date.='</tr>';
 		 }
 		     echo $date;
 		     ?>

    <!-- 自定义函数传值  -->     

    <?php
          $arr=[
                   ['id'=>10,'name'=>'欧阳锋','age'=>57,'sex'=>1,'email'=>'ou@php.cn','password'=>sha1('123456')],
                   ['id'=>11,'name'=>'郭靖',  'age'=>25,'sex'=>2,'email'=>'hr@php.cn','password'=>sha1('123456')],
               ];

               function liuhong($lnn)
{
   
    $result = '';
     
    foreach ($lnn as $lnns)
    {
        $result .= '<tr>';
        $result .= '<td>' . $lnns['id'] . '</td>';
        $result .= '<td>' . $lnns['name'] . '</td>';
        $result .= '<td>' . $lnns['age'] . '</td>';
        $result .= '<td>' . ($lnns['sex'] ? '男' : '女') . '</td>';
        $result .= '<td>' . $lnns['email'] . '</td>';
        $result .= '<td>' . $lnns['password'] . '</td>';
        $result .= '</tr>';

    }
    return $result;
}
         echo liuhong($arr)

     ?>

 	</tbody>
 </table>
 <p>总计:11人</p>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Correction status:Uncorrected

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