PHP练习

By admin, 17 十一月, 2016

用PHP实现包含以下表格的页面,其中表格的内容不能直接填进去,要先用写到PHP数组里,再想办法从数组里获取组装成表格。                                                                                       

学号 姓名 年级 班别
1101 陈一 一年级 1
1102 袁二 一年级 1
1203 张三 一年级 2
2104 李四 二年级 1
2205 王五 二年级 2

 

提示:

  1. 先写一个php后缀的页面,里面可以不包含任何PHP代码,把之前CSS练习的代码复制过来也能显示该表格。参考:http://www.w3school.com.cn/php/php_syntax.asp
  2. 创建两个PHP数组变量,$header = array('学号', '姓名', '年级', '班别'); $rows = array(array('1101', '陈一', '一年级', 1), array('1102', ...), ...); 省略号内容请自己补全。参考:http://www.w3school.com.cn/php/php_arrays.asp
  3. 通过循环语句(参考:http://www.w3school.com.cn/php/php_looping_for.asp)和字符串拼接(参考:http://www.w3school.com.cn/php/php_operators.asp里的PHP 字符串运算符)的方式构造成之前纯HTML的代码。
  4. 需要注意的是,PHP语言和JavaScript语言有许多相似之处(计算机高级语言之间都有很多相似之处),不要混淆。

评论

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
验证码
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
请输入"Drupal10"