Home  >  Article  >  Backend Development  >  How to teach female students to develop PHP from scratch: writing requirements documents_PHP tutorial

How to teach female students to develop PHP from scratch: writing requirements documents_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:19:02901browse

Background: A female high school classmate in Beijing asked me to help her be her "technical consultant" for practical training. The practical training required individuals to independently develop a web project. The development language she chose was php. In fact, I became a clickbait again. Although she has never used PHP before, she has a little basic knowledge of html, css, and javascript (she has forgotten them all), and has written things in C and java.

Project description:

Title - Resource Reservation Management System

Functional requirements——

1. Develop a resource reservation management system for enterprises and institutions

2. Provide employees with the function of making reservations for different types of resources, such as conference rooms, cars, instruments and equipment, etc.

3. After employees log in to the system, they can view the current reservation status of the specified resources and reserve idle resources within the specified time period.

4. Different resources need to set different opening hours according to the situation, such as 8:00 to 18:00 every day, for intelligent reservation during development time

5. The minimum time unit that can be reserved for different resources is different. For example, a conference room can be reserved by the minute, with a minimum of 15 minutes, and a car can be reserved by the hour, with a minimum of 2 hours.

6. The system makes reservations on a first-come, first-served basis.

7. After a user has made a reservation, he or she can cancel it before using it. After cancellation, other users can continue to make reservations

Step one: Write requirements document

Students majoring in computer science have generally taken software engineering courses, so they naturally know the importance of meeting requirements. Even if you have not taken it, comrades who have work experience should have read the requirements documents written by others. If the completion of a project is compared to building a house, then the requirements are like architectural design drawings. If the design is not good, the built house will not look good. Although software development has greater flexibility than architecture (at least the house cannot roll back the code and undo changes at every turn), if the requirements are not comprehensive and rigorous, it will often greatly increase unnecessary workload and reduce work efficiency.

Think about it, today I tell you such a requirement, you have written half of the code, and a few days later I tell you that the requirement has changed, and the previous code is useless. How do you feel? Although demand changes are common, once the demand gets out of control, the impact on the project is often catastrophic.

Fortunately, the girl had written requirements documents when she was designing desktop software courses. Otherwise, it would have been quite troublesome to learn how to make requirements from scratch. However, it would be a big mistake for a newbie to not do the requirements because they find it troublesome. Regardless of whether they will be exposed to more rigorous requirements documents after entering a formal job, even if they are just dealing with curriculum design in school, when the software scale is large enough, , it takes one day to complete the requirements, which can at least shorten the development time by one week.

Step 2: Example of login page

The girl is writing requirements documents, so I can’t be idle either. Because I have only read a little bit about PHP before, and have never written a line of code in PHP. In order to stay ahead of girls, I must learn in advance what girls need to use. Since the project designed for this course has a login function, I plan to use this page as the first example to introduce PHP, and will provide a more detailed explanation of the entire process of the login function in the future.

First, let’s look at the simplest html login page and add the code!

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><</span><span class="tag-name">html</span><span class="tag">></span><span> </span></span></li>
<li>
<span> </span><span class="tag"><</span><span class="tag-name">head</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span> </span><span class="tag"><</span><span class="tag-name">meta</span><span> </span><span class="attribute">charset</span><span>=</span><span class="attribute-value">"gbk"</span><span class="tag">></span><span> </span>
</li>
<li>
<span> </span><span class="tag"><</span><span class="tag-name">title</span><span class="tag">></span><span>用户登录界面</span><span class="tag"></</span><span class="tag-name">title</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span> </span><span class="tag"></</span><span class="tag-name">head</span><span class="tag">></span><span> </span>
</li>
<li>
<span> </span><span class="tag"><</span><span class="tag-name">body</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span> </span><span class="tag"><</span><span class="tag-name">form</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"login"</span><span> </span><span class="attribute">action</span><span>=</span><span class="attribute-value">"Controller.php"</span><span> </span><span class="attribute">method</span><span>=</span><span class="attribute-value">"post"</span><span> </span><span class="tag">></span><span>     </span>
</li>
<li>
<span> </span><span class="tag"><</span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"tbl"</span><span class="tag">></span><span>用户名:</span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"text"</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"user_id"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span>      </span>
</li>
<li class="alt">
<span>     </span><span class="tag"><</span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"tbl"</span><span class="tag">></span><span>密码:</span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"text"</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"user_password"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span> </span>
</li>
<li>
<span>     </span><span class="tag"><</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"submit"</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"登入系统"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span> </span><span class="tag"></</span><span class="tag-name">form</span><span class="tag">></span><span> </span>
</li>
<li>
<span> </span><span class="tag"></</span><span class="tag-name">body</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span class="tag"></</span><span class="tag-name">html</span><span class="tag">></span><span> </span>
</li>
</ol>

In order to prevent everyone from reaching out to the extreme, I will not upload a screenshot of the page. You can copy the code and use the browser to see the effect. Why do I need to write these lines of code for my girl? The main purpose is to let the girl become familiar with what html code looks like, and to pave the way for the following to let the girl know why php and html are mixed together. After a while, you should have seen the display effect of the above codes. In this case, please look at the code after adding php below:

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><?</span><span class="tag-name">php</span><span>         //php代码部分开始  </span></span></li>
<li>
<span>echo "</span><span class="tag"><</span><span class="tag-name">html</span><span class="tag">></span><span>";  </span>
</li>
<li class="alt">
<span>echo "</span><span class="tag"><</span><span class="tag-name">head</span><span class="tag">></span><span>";  </span>
</li>
<li>
<span>echo "</span><span class="tag"><</span><span class="tag-name">meta</span><span> </span><span class="attribute">charset</span><span>=\"gbk\"</span><span class="tag">></span><span>";  </span>
</li>
<li class="alt">
<span>echo "</span><span class="tag"><</span><span class="tag-name">title</span><span class="tag">></span><span>用户登录界面</span><span class="tag"></</span><span class="tag-name">title</span><span class="tag">></span><span>";  </span>
</li>
<li>
<span class="tag">?></span><span class="comments"><!--  php代码部分结束--></span><span> </span>
</li>
<li class="alt">
<span class="tag"></</span><span class="tag-name">head</span><span class="tag">></span><span> </span>
</li>
<li>
<span class="tag"><</span><span class="tag-name">body</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span class="tag"><</span><span class="tag-name">form</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"login"</span><span> </span><span class="attribute">action</span><span>=</span><span class="attribute-value">"Controller.php"</span><span> </span><span class="attribute">method</span><span>=</span><span class="attribute-value">"post"</span><span> </span><span class="tag">></span><span> </span>
</li>
<li>
<span>     </span><span class="tag"><</span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"tbl"</span><span class="tag">></span><span>用户名:</span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"text"</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"user_id"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span>      </span>
</li>
<li class="alt">
<span>     </span><span class="tag"><</span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"tbl"</span><span class="tag">></span><span>密码:</span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"text"</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"user_password"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span> </span>
</li>
<li>
<span class="tag"><?</span><span class="tag-name">php</span><span>      </span>
</li>
<li class="alt">
<span>echo "</span><span class="tag"><</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=\"submit\" </span><span class="attribute">value</span><span>=\"登入系统\"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span>"  </span>
</li>
<li>
<span class="tag">?></span><span> </span>
</li>
<li class="alt">
<span class="tag"></</span><span class="tag-name">form</span><span class="tag">></span><span> </span>
</li>
<li>
<span class="tag"></</span><span class="tag-name">body</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span class="tag"></</span><span class="tag-name">html</span><span class="tag">></span><span> </span>
</li>
</ol>

This code mainly allows girls to understand the following points: 1) PHP code must be identified with the tag 2) How to use the echo statement to output html code, and about the use of the correct "" "(double quotes) escape with escape character). 3) How the php code is mixed with the html code.

PS: It’s hard to start from the beginning, so I have to write so much in the first article. It is not good to set the starting point too high, as it can easily confuse beginners. Look at the code as an example, change it yourself, write it, and get a feel for it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/601050.htmlTechArticleBackground: A female high school classmate in Beijing asked me to help her be her technical consultant for practical training. The practical training requires individuals Developing a web project independently, the development language she chose was php. In fact, I became a fool again...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn