


Teach you step by step how to do a keyword matching project (search engine) ---- On the thirteenth day, teach you how to do it on the thirteenth day_PHP tutorial
Teach you step-by-step how to do keyword matching projects (search engines)----On the thirteenth day, teach you how to do it on the thirteenth day
Thirteenth day
Ever since Xiao Shuai Shuai was gangbanged by Mr. Yu, I feel very unhappy because there is this reason: I have done what you want, why can’t I get recognition.
What kind of programmer is good? Xiao Shuai Shuai went to understand the design pattern with such questions.
Although he has read design patterns many times, he even knows the names of design patterns by heart, such as singleton pattern, abstract factory pattern, builder pattern, factory pattern, prototype pattern...etc.
But Xiao Shuaishuai still didn’t know how to use it. He had no choice but to ask Boss Yu again. Boss Yu gave him a copy of the code to look at and see what design patterns were used in it.
What kind of programmer is good? Some people say that good programmers write code that can be read, while ordinary programmers write code that can run.
Yu Boss’s code is as follows:
<?<span>php </span><span>class</span><span> SelectorItem { </span><span>private</span> <span>$item</span><span>; </span><span>public</span> <span>function</span> __construct(<span>$item</span><span>){ </span><span>$this</span>->item = <span>$item</span><span>; } </span><span>public</span> <span>function</span> __get(<span>$name</span><span>){ </span><span>if</span>(<span>isset</span>(<span>$this</span>->item-><span>$name</span><span>)){ </span><span>return</span> <span>$this</span>->item-><span>$name</span><span>; } </span><span>return</span> <span>null</span><span>; } </span><span>public</span> <span>static</span> <span>function</span> createFromApi(<span>$num_iid</span><span>){ </span><span>$client</span> = <span>new</span><span> TopClient(); </span><span>$client</span>->appkey = 'xx'<span>; </span><span>$client</span>->secretKey = 'xx'<span>; </span><span>$req</span> = <span>new</span><span> ItemGetRequest(); </span><span>$req</span>->setFields('props_name,property_alias,detail_url,cid,title'<span>); </span><span>$req</span>->setNumIid(<span>$num_iid</span><span>); </span><span>$resp</span> = <span>$client</span>->execute(<span>$req</span><span>); </span><span>if</span>(<span>isset</span>(<span>$resp</span>-><span>code)){ </span><span>#</span><span> error handle</span> <span>throw</span> <span>new</span> <span>Exception</span>(<span>$resp</span>->msg, <span>$resp</span>-><span>code); } </span><span>return</span> <span>new</span> self(<span>$resp</span>-><span>item); } } </span><span>class</span><span> CharList { </span><span>private</span> <span>$core</span> = <span>array</span><span>(); </span><span>private</span> <span>$blacklist</span> = <span>array</span><span>(); </span><span>public</span> <span>function</span> addCore(<span>$char</span><span>){ </span><span>if</span>(!<span>in_array</span>(<span>$char</span>,<span>$this</span>-><span>core)) </span><span>$this</span>->core[] = <span>$char</span><span>; } </span><span>public</span> <span>function</span><span> getCore(){ </span><span>return</span> <span>$this</span>-><span>core; } </span><span>public</span> <span>function</span> addBlacklist(<span>$char</span><span>){ </span><span>if</span>(!<span>in_array</span>(<span>$char</span>,<span>$this</span>-><span>blacklist)) </span><span>$this</span>->blacklist[] = <span>$char</span><span>; } </span><span>public</span> <span>function</span><span> getBlacklist(){ </span><span>return</span> <span>$this</span>-><span>blacklist; } } </span><span>abstract</span> <span>class</span><span> CharListHandle { </span><span>protected</span> <span>$charlist</span><span>; </span><span>public</span> <span>function</span> __construct(<span>$charlist</span><span>){ </span><span>$this</span>->charlist = <span>$charlist</span><span>; } </span><span>abstract</span> <span>function</span> <span>exec</span><span>(); } </span><span>class</span> MenCharListHandle <span>extends</span><span> CharListHandle { </span><span>public</span> <span>function</span> <span>exec</span><span>(){ </span><span>$this</span>->charlist->addCore("男装"<span>); </span><span>$this</span>->charlist->addBlacklist("女"<span>); } } </span><span>class</span> WomenCharListHandle <span>extends</span><span> CharListHandle{ </span><span>public</span> <span>function</span> <span>exec</span><span>(){ </span><span>$this</span>->charlist->addCore("女装"<span>); </span><span>$this</span>->charlist->addBlacklist("男"<span>); } } </span><span>#</span><span> 其他CharList Handle小帅帅完成</span> <span>class</span><span> Selector { </span><span>private</span> <span>static</span> <span>$charListHandle</span> = <span>array</span><span>( </span>"男装"=>"MenCharListHandle", "女装"=>"WomenCharListHandle", "情侣装"=>"LoversCharListHandle", "童装"=>"ChildrenCharListHandle"<span> ); </span><span>public</span> <span>static</span> <span>function</span> select(<span>$num_iid</span><span>){ </span><span>$selectorItem</span> = SelectorItem::createFromApi(<span>$num_iid</span><span>); Logger</span>::trace(<span>$selectorItem</span>-><span>props_name); </span><span>$matchTitle</span> = <span>$selectorItem</span>->title.<span>$selectorItem</span>-><span>props_name; </span><span>$charlist</span> = <span>new</span><span> CharList(); </span><span>foreach</span>(self::<span>$charListHandle</span> <span>as</span> <span>$matchKey</span>=><span>$className</span><span>){ </span><span>if</span>(<span>preg_match</span>("/<span>$matchKey</span>/",<span>$matchTitle</span><span>)){ </span><span>$handle</span> = self::createCharListHandle(<span>$className</span>,<span>$charlist</span><span>); </span><span>$handle</span>-><span>exec</span><span>(); } } </span><span>//</span><span>do search things </span> <span> } </span><span>public</span> <span>static</span> <span>function</span> createCharListHandle(<span>$className</span>,<span>$charlist</span><span>){ </span><span>if</span>(<span>class_exists</span>(<span>$className</span><span>)){ </span><span>return</span> <span>new</span> <span>$className</span>(<span>$charlist</span><span>); } </span><span>throw</span> <span>new</span> <span>Exception</span>("class not exists",0<span>); } }</span>
After Xiao Shuaishuai read the code, he couldn’t hold it any longer . This is the legendary Boss Yu, and he didn’t copy my code. . .
What would Boss Yu do if he heard Xiao Shuai Shuai’s thoughts?
Xiao Shuai Shuai can’t continue to study the magic secrets.

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Adjusting the aperture size has a crucial impact on the photo effect. Xiaomi Mi 14 Ultra provides unprecedented flexibility in camera aperture adjustment. In order to allow everyone to adjust the aperture smoothly and realize the free adjustment of the aperture size, the editor here brings you a detailed tutorial on how to set the aperture on Xiaomi Mi 14Ultra. How to adjust the aperture on Xiaomi Mi 14Ultra? Start the camera, switch to "Professional Mode", and select the main camera - W lens. Click on the aperture, open the aperture dial, A is automatic, select f/1.9 or f/4.0 as needed.

Fermat's last theorem, about to be conquered by AI? And the most meaningful part of the whole thing is that Fermat’s Last Theorem, which AI is about to solve, is precisely to prove that AI is useless. Once upon a time, mathematics belonged to the realm of pure human intelligence; now, this territory is being deciphered and trampled by advanced algorithms. Image Fermat's Last Theorem is a "notorious" puzzle that has puzzled mathematicians for centuries. It was proven in 1993, and now mathematicians have a big plan: to recreate the proof using computers. They hope that any logical errors in this version of the proof can be checked by a computer. Project address: https://github.com/riccardobrasca/flt

Ce Modifier (CheatEngine) is a game modification tool dedicated to modifying and editing game memory. So how to set Chinese in CheatEngine? Next, the editor will tell you how to set Chinese in Ce Modifier. I hope it can Help friends in need. In the new software we download, it can be confusing to find that the interface is not in Chinese. Even though this software was not developed in China, there are ways to convert it to the Chinese version. This problem can be solved by simply applying the Chinese patch. After downloading and installing the CheatEngine (ce modifier) software, open the installation location and find the folder named languages, as shown in the figure below

Apple rolled out the iOS 17.4 update on Tuesday, bringing a slew of new features and fixes to iPhones. The update includes new emojis, and EU users will also be able to download them from other app stores. In addition, the update also strengthens the control of iPhone security and introduces more "Stolen Device Protection" setting options to provide users with more choices and protection. "iOS17.3 introduces the "Stolen Device Protection" function for the first time, adding extra security to users' sensitive information. When the user is away from home and other familiar places, this function requires the user to enter biometric information for the first time, and after one hour You must enter information again to access and change certain data, such as changing your Apple ID password or turning off stolen device protection.

Honor 90GT is a cost-effective smartphone with excellent performance and excellent user experience. However, sometimes we may encounter some problems, such as how to update Honor MagicOS8.0 on Honor 90GT? This step may be different for different mobile phones and different models. So, let us discuss how to upgrade the system correctly. How to update Honor MagicOS 8.0 on Honor 90GT? According to news on February 28, Honor today pushed the MagicOS8.0 public beta update for its three mobile phones 90GT/100/100Pro. The package version number is 8.0.0.106 (C00E106R3P1) 1. Ensure your Honor The battery of the 90GT is fully charged;

Recent news, lackMagic has launched the 18.5PublicBeta2 public beta update of the DaVinci Resolve Studio video editing software, bringing AV1 encoding support to AMD Radeon graphics cards. After updating to the latest version, AMD graphics card users will be able to take advantage of hardware acceleration for AV1 encoding in DaVinci Resolve Studio. Although the official does not specify the supported architectures or models, it is expected that all AMD graphics card users can try this feature. In 2018, AOMedia released a new video coding standard AV1 (AOMediaVideoCodec1.0). AV1 is produced by a number of

Popular Metaverse game projects founded in the last crypto cycle are accelerating their expansion. On March 4, PlanetMojo, the Web3 game metaverse platform, announced a number of important developments in its game ecology, including the announcement of the upcoming parkour game GoGoMojo, the launch of the new season "Way of War" in the flagship auto-chess game MojoMelee, and the celebration of the new The first ETH series "WarBannerNFT" launched this season in cooperation with MagicEden. In addition, PlanetMojo also revealed that they plan to launch Android and iOS mobile versions of MojoMelee later this year. This project will be launched at the end of 2021. After nearly two years of hard work in the bear market, it will soon be completed.

Answer: Yes, Golang provides functions that simplify file upload processing. Details: The MultipartFile type provides access to file metadata and content. The FormFile function gets a specific file from the form request. The ParseForm and ParseMultipartForm functions are used to parse form data and multipart form data. Using these functions simplifies the file processing process and allows developers to focus on business logic.
