Home > Backend Development > PHP Tutorial > Teach you step by step how to do a keyword matching project (search engine) ---- Day 11, teach you how to do it on the eleventh day_PHP Tutorial

Teach you step by step how to do a keyword matching project (search engine) ---- Day 11, teach you how to do it on the eleventh day_PHP Tutorial

WBOY
Release: 2016-07-13 10:20:54
Original
942 people have browsed it

Teach you step by step how to do keyword matching projects (search engines) ---- Day 11, teach you how to do it on Day 11

Day 11

Starting point:

1. Teach you step by step how to do keyword matching project (search engine) ---- Day 1

Review:

10. Teach you step by step how to do keyword matching project (search engine) ---- Day 10

It’s the weekend again, and Xiao Shuaishuai has to write a summary report again. Xiao Shuaishuai doesn’t like making summaries a bit. He thinks that writing code is better than writing a summary.

But it was a task assigned by Boss Yu, and he had to complete it.

1. Cultivation of object-oriented programming thinking ability

2. Use and reconstruction of TopClient

3. In-depth use of ExtendedCurl

4. Creation and application of Logger

As soon as Xiao Shuaishuai wrote this, he still thinks about the three questions asked by Boss Yu. Even if he wrote the code, he still can't figure out why Boss Yu will predict the future.

Xiao Shuai Shuai’s code is as follows:

<span>class</span><span> Logger {

    </span><span>const</span> LEVEL_TRACE='trace'<span>;
    </span><span>const</span> LEVEL_WARNING='warning'<span>;
    </span><span>const</span> LEVEL_ERROR='error'<span>;

    </span><span>public</span> <span>static</span> <span>function</span> error(<span>$message</span><span>){
        self</span>::<span>log</span>(<span>$message</span>,self::<span>LEVEL_ERROR);
    }

    </span><span>public</span> <span>static</span> <span>function</span> warning(<span>$message</span><span>){
        self</span>::<span>log</span>(<span>$message</span>,self::<span>LEVEL_WARNING);
    }

    </span><span>public</span> <span>static</span> <span>function</span> trace(<span>$message</span><span>){
        </span><span>if</span><span>(DEBUG)
            self</span>::<span>log</span>(<span>$message</span>,self::<span>LEVEL_TRACE);
    }

    </span><span>public</span> <span>static</span> <span>function</span> <span>log</span>(<span>$message</span>,<span>$level</span> = self::<span>LEVEL_TRACE){
        </span><span>$file</span> = <span>fopen</span>('application.error.log', "a+"<span>);
        </span><span>fwrite</span>(<span>$file</span>, <span>$message</span>."\t".<span>$level</span>."\t".<span>microtime</span>(<span>true</span><span>));
        </span><span>fclose</span>(<span>$file</span><span>);
    }
}</span>
Copy after login

The question that Xiao Shuai Shuai couldn’t figure out was what he liked to ask, so he had to go to Boss Yu again.

Boss Yu said: You are all people who meet the needs when doing functions. Have you ever thought about it, in fact, you are also people who make needs. Do you know about test-driven development?

Test-Driven Development: The full English name is Test-Driven Development, or TDD for short. It is a new development method that is different from the traditional software development process. It requires writing test code before writing the code for a certain function, and then only writing the functional code that makes the test pass, and driving the entire development through testing. This helps write concise, usable and high-quality code and speeds up the development process. [From Baidu Dictionary]

Test-driven development well describes user input and results.

Think of yourself as a person making demands and look at the problem from the perspective of the person making the demands.

In fact, Xiao Shuaishuai was also wondering when he wrote this code. If he uses the following statement, he can record all the problems.

Logger::<span>log</span>(<span>$message</span>,'error'<span>);
Logger</span>::<span>log</span>(<span>$message</span>,'warning'<span>);
Logger</span>::<span>log</span>(<span>$message</span>,'trace');
Copy after login

Why did Boss Yu bring it up separately:

Logger::error(<span>$message</span><span>);
Logger</span>::warning(<span>$message</span><span>);
Logger</span>::trace(<span>$message</span>);
Copy after login

Boss Yu said to him: Which of the above two methods do you prefer to use?

Demanderers like simple functions

(In fact, it fully reflects their lazy behavior, which is why we have the current civilization)

After reading this, Xiao Shuaishuai was deeply shocked. He felt the importance of theoretical knowledge and mentality like never before.

For the first time, Xiao Shuaishuai felt that there are so many things to learn...

Xiao Shuaishuai is not in a hurry. The task is still important. He firmly believes that as long as he completes more projects, he can become a great person.

He had no choice but to find Boss Yu in a hurry and ask for advice on how to apply keywords and how to implement technology.

But Boss Yu didn’t want to say any more, and wanted Xiao Shuaishuai to think for himself.

This is really hard for Xiao Shuai Shuai.

This is the time for Xiao Shuai Shuai to stand up....

Keyword application requirements:

The product title and product attributes obtained through Taobao API are matched with keywords suitable for the product.

Consider the following factors initially:

Matching suitable for the group of people: Men’s clothing (matched keywords cannot contain women) Women’s clothing (matched keywords cannot contain men) Couples clothing (applicable to both men and women) Children’s clothing (?)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/864308.htmlTechArticleTeach you step by step how to do keyword matching projects (search engines) ---- On the eleventh day, teach you how to do it Day 11 Starting point for day 11: 1. Teach you step by step how to do keyword matching project (search engine)...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template