Home >Backend Development >PHP Tutorial >A good article on object-oriented PHP development model (abbreviated version)_PHP tutorial
I saw some people criticizing PHP, why this part is not easy to use, and that part is not easy to use. In fact, strictly speaking, no language is easy to use, and no language has strict standards. Everything has a development process. We can't wait for these standards to be perfect before using them, right? I think no matter what language you use, you have to rely on yourself when writing programs. A programmer must have a good style, ideas, etc. I've been sorting out some information recently, and I'm sending some out now. I hope everyone can give me more opinions and support.
======================== ===============
Object-oriented PHP development model (to be improved...)
================ =======================
1. Environment
Server: Linux (Apache 2.x, MySQL4.1.x, PHP4, Perl, SHELL, CVS, Sambar)
Client: Windows (Ie6, UltraEdit, other auxiliary tools)
Test machine: windows98/2K/xp/Linux (Ie5, Ie6, mozilla, firefox)
2. Three layers of web pages, programs and databases
The so-called web pages are not ordinary static web pages. The web pages here are templates made of HTML after being split
according to the specific situation of the project analysis; The database here includes database and interface programs with other parts. Usually programs and database
programs may be mixed in one file, but they should be separated as much as possible using functions. If other programs want to use data
The library can directly call these functions and cannot directly access SQL statements.
3. Project Analysis - Data Analysis
After a project has received demand analysis, the first step before actual development is data analysis. Data analysis is to
pile up all kinds of data that will be used in the project process, classify them according to their characteristics and organize them separately. Of course
there may be various kinds of data between them. relationship. Doing this step well will give the project analysis work a good start, and also provide great convenience for the following project structure analysis and data processing process analysis.
4. Project Analysis - Data Abstraction
After data analysis, we should be able to have some rough data models and some basic data small models combined
into a large model in our minds. Generally, In this case, we create a database for maintenance of some data that needs to be changed, and make some constants for the data that does not need to be changed, and abstract relevant classes for these data types, and establish relevant methods for database operations. >Relationship interface (function form, that is, method), data and data-related operations can also abstract some basic methods,
We only need to call them in programming.
5. Project Analysis - Interface Analysis
We have analyzed the data with the purpose of combining one or several products, and since we want to make a product, we need to show it to others.
So we still need to design the interface. After considering the various interfaces as comprehensively as possible, we will make the designed interface into a template, and
write the corresponding processing interface program (so, in the eyes of the program, the interface is also A kind of data), used when writing programs.
6. Project Analysis - Process Design
The website program is very simple, just follow the process to call various data we designed.
7. Case Analysis
User system, now we analyze the simplest example, a user system.
1. Data analysis, we analyze the simplest user system, so there are only two data here, that is the user name
and password. If we continue the analysis, we will also think that we should add a number (id) to each record ), now that there are three data, there is really nothing
to add.
2. Data abstraction, a data model with only three data, thinking of its possible operation methods, we make the following arrangements,
Database interface (savetodb(), getfromdb(), delete()), respectively There is also deletion of data entering and exiting the database; changing the password (password()). In addition, considering the management and viewing of the user system, there will be a collection type of data (list).
3. Interface analysis, login, verification successful, verification error, change password, change password successfully, change password error, user registration with
, registration successful, registration error; management - user list, management - user Information viewing, management - modify user
password, management - delete user.
4. Sample code
PHP code:
Copy code