Home > Article > Backend Development > Teach you step by step how to do a keyword matching project (search engine) ---- Day 10, teach you how to do it on the tenth day_PHP Tutorial
Day 10
Starting point:
1. Teach you step by step how to do keyword matching project (search engine) ---- Day 1
Review:
9. Teach you step by step how to do keyword matching project (search engine)----Day 9
After Xiao Shuai Shuai received the task of recording the Log, he went to study it with peace of mind. . .
In fact, according to Boss Yu’s level, he is used to open source frameworks and writing an ordinary Logger is easy. Why does he want Xiao Shuaishuai to do it?
Xiao Shuai Shuai actually couldn’t figure it out at the time because he had never experienced that stage.
Xiao Shuai Shuai’s idea is actually quite simple, which is to complete the tasks given by his boss and become a good employee who can do the job.
Xiao Shuai Shuai is not sensitive to needs at this stage, so he went to study the technical details as soon as he received the task. Little did they know that the code had already been written.
Xiao Shuaishuai’s first draft is to try to use object-oriented thinking to write the task of recording Log. The first draft is as follows:
<span>class</span><span> Logger { </span><span>public</span> <span>static</span> <span>function</span> <span>log</span>(<span>$message</span><span>){ </span><span>$file</span> = <span>fopen</span>('application.error.log', "a+"<span>); </span><span>fwrite</span>(<span>$file</span>, <span>$message</span><span>); </span><span>fclose</span>(<span>$file</span><span>); } }</span>
Then the code of TopClient is as follows:
<span>class</span><span> TopClient { </span>...... <span>protected</span> <span>function</span> logCommunicationError(<span>$apiName</span>, <span>$requestUrl</span>, <span>$errorCode</span>, <span>$responseTxt</span><span>) { </span><span>$localIp</span> = <span>isset</span>(<span>$_SERVER</span>["SERVER_ADDR"]) ? <span>$_SERVER</span>["SERVER_ADDR"] : "CLI"<span>; </span><span>$logData</span> = "API_NAME:<span>$apiName</span>,APP_KEY:<span>$this</span>->appkey,CLIENT_IP:<span>$localIp</span>,SDK_VERSION:<span>$this</span>->sdkVersion,REQUEST_URL:<span>$requestUrl</span>,ERROR_CODE:<span>$errorCode</span>,ERROR_MSG:".<span>str_replace</span>("\n","",<span>$responseTxt</span><span>); Logger</span>::<span>log</span>(<span>$logData</span><span>); } </span>......<span> }</span>
In fact, this is a progress, Xiao Shuai Shuai is finally slowly changing his thinking ability.
When Xiao Shuaishuai found Boss Yu with this code, Boss Yu was very happy, but it was not the result he wanted, so Boss Yu said to Xiao Shuaishuai:
1. If you want to record error logs, how do you expect to use it and what information do you expect to see.
2. If you want to record a warning log, how do you expect to use it and what information do you expect to see.
3. If you want to debug and see the execution efficiency of the code, how do you expect to use it, and what information do you expect to see.
Why did the three of them overwhelm Xiao Shuai Shuai? When Xiao Shuai Shuai heard this, he was a little angry and couldn't get over.
Just like that, Xiao Shuai Shuai thought about what Boss Yu said.
When Xiao Shuai Shuai is lucky enough to understand the meaning, the mental method he learned will be more powerful. We hope that Xiao Shuai Shuai will be able to understand it.
Currently, Baidu promotion has three matching methods: precise, phrase, and broad. Generally speaking, the golden combination matching method is: broad matching + search term report + negative keywords. In terms of traffic, it's broad>phrase>accurate. You can set it according to your actual situation!
Okay, give me the red flag,