FYB php框架——开篇,fybphp框架
目标: 学习型PHP框架、框架的代码少、 简单易懂、 方便拓展、 完全面向对象、
新手还是练好基本知识,尤其是对数组的操作,以及MVC模式这个可能以后用得很多,其次把数据库学好这样才有利于框架的学习,
框架其实就是按照这个框架定义的一些语法来进行扩展开发,可能利用他的架构会增加代码的重复利用。目前比较流行的是ZF,YII 以及国内的THINKPHP,不过说到底,框架都是MVC模式,以后也可以自己写的。
平常我也不发言。今天写个代码给你看看:简单的Model层
product.class.php:
class product{
public function getAllProducts(){
$q="SELECT * FROM Product";
$r=$db->query($q);
$proArr=array();
while($row=db->fetchAssoc($r)){
$proArr[]=$row;
}
return $proArr;
}
}
?>
视图和控制层:
getallproducts.php:
$product=new product();
$ps=$product->getAllProducts();
foreach($ps as $p){
//输出数据库中查出来的
echo $p['name'];
}
我一般就是这样写的 PHP说多了,就是大部分对数组进行编程 ,
大部分都是在页面里输出SQL语句,嵌套HTML,显得页面臃肿,不易维护和扩展
这样分层以后修改比较简单

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
