Blogger Information
Blog 27
fans 0
comment 0
visits 17279
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
014-PHP第四节-数组应用实例讲解
冇忉丼
Original
593 people have browsed it

总结

由一个电视剧app界面入手,资源列表-数组-数据库数据三者结合,核心位置为php中的数组。
1.数据库的二维数据提出来,老师并未做一个二维的数组,类似

  1. [
  2. a=>[
  3. ],
  4. b=>[
  5. ],
  6. ];

而是做了一个三维的关联数组,讲解了关联数组的便利性:不必对严格按分类排序作要求。
2.接着,讲了在html标签中嵌入php数组循环(二维入手):

  1. foreach($data['title'] as $v){
  2. echo '<li>' . $v . '<li>';
  3. }

循环title下元素个数的次数,三维数组类推,多一个foreach。
3.列表链接到外部php文件,作为界面切换,因为这些php文件有很多重复代码
所以将这些重复代码单独提到一个php文件里,按照先后顺序排列。引入方式

  1. include 'xx.php';//有错误继续执行,只警告
  2. require 'yy.php';//有错误不执行
  3. //魔术常量 __dir__坑待补,仅知是绝对路径,可参见链接https://blog.csdn.net/leipanbo/article/details/78581509
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