- ?? ????? ?? ??
-
SlimMiddleware
?? ? ???? ?? ? ??? ??? ????, ??? ? ?? ???????. ??? ??? ?????. ? ? ???? ?? ?? ? ??? ???? ?? ????? ????? ?? ? ???. ??? ????? ??? ?? ?? ? ???? : call()
-
??? ??? ??? ???? ??? ?? ??? ???? ???? ???? ?? ??? ?? ?? ?? ? ?? ?????. ?? ????? ? ??? ???? ?? ???? ??? ????? ?????. ?? ???? ??? ????? ??????. ??? ?? ?? ????? ???? HTTP 401 ??? ?????. ?? ?? ?? ? ?? ??? ??? ? ??? ??????. ???? ???? ?? ? ??? ???? ????? ?????. ????? ????? ???? ???? ??? ?? ? ??? ?? ???? ????? ? ????. ??? ???? ??? ?? ?? ?? ????? ?? ??????. ?? ??, ?? ????? ??? ??? ??? ??? ?? ???? ??? ?????. add()
add()
???? ??
???? ????? ???? ???????. ????? ?? ??? ?????,? ??? ??? ?? (?? ????? ??)??? ?? ???? ?? ? ? ????.
<?php namespace MyMiddleware; class Cache extends SlimMiddleware { protected $db; public function __construct(PDO $db) { $this->db = $db; } public function call() { $key = $this->app->request()->getResourceUri(); $rsp = $this->app->response(); $data = $this->fetch($key); if ($data) { // 緩存命中...返回緩存的內(nèi)容 $rsp["Content-Type"] = $data["content_type"]; $rsp->body($data["body"]); return; } // 緩存未命中...繼續(xù)生成頁面 $this->next->call(); if ($rsp->status() == 200) { // 緩存結(jié)果以供將來查找 $this->save($key, $rsp["Content-Type"], $rsp->body()); } } protected function fetch($key) { $query = "SELECT content_type, body FROM cache WHERE key = " . $this->db->quote($key); $result = $this->db->query($query); $row = $result->fetch(PDO::FETCH_ASSOC); $result->closeCursor(); return $row; } protected function save($key, $contentType, $body) { $query = sprintf("INSERT INTO cache (key, content_type, body) VALUES (%s, %s, %s)", $this->db->quote($key), $this->db->quote($contentType), $this->db->quote($body) ); $this->db->query($query); } }? ??> <<> ??? ?? ???? ???? ??? ? ??? ??????. ???? ???
?? ? ??? ?? ? ?? ???? ??? ??? ?????. ??? ???? ? ??>? ???? ?? ???? ??? ??????. ????? ?? ???? ?? ??? ???? ?? ?? ?? ??? ??? ???? ?? ???? ?? ??? ?? ?????. ? ???? Slim? call()
???? ???? ??? ? ??>? ?? ?? ?? ????? ????? ????? ????? ?? ? ?? ??? ??? ? ? ????. ??? ??? ???? ??? ??? ??? ? ? ??? Content-Type
??? ?? ?? ??? ??? ????. ? ??> ? $this->next->call()
???? ?? ? ??? ????, ??? ???? ?? ???? ?? ?????? ??? ?????. ?? ??? ???? ?? ??? ?????. ? ?? Middleware
, $this->app
? ? body()
??? ? ??>?? ???? ??? ?????. ??? ?? ?? ????? ?? ? ????. ?? ?? ? (???) ?? ? ??? ??? ???? ??? ?? ?? ? ? ????. fetch()
save()
<<> ????? ?? ? ?? ? ??> cache
key
???? ???? ????? ??????. content_type
body
??
???? ????? ??? ??? ?? ? ? ????.?? ?? ?? ???? ????? ?? ??? ???? IT ?? ??? ????. ?? ?? ??? ??? ??? ?????. add()
? ??> <<> ??
<?php require_once "../vendor/autoload.php"; $app = new SlimSlim(); $app->add(new MyMiddlewareCache($db));
(Fotolia? ??)
(??? ?? ???? ?? ?? ? ?? ? FAQ?? ?? ?? ???? ????????) ?? ????? ?? FAQS
?? ????? ???? ? ?????? Slim Middleware? Slim Framework? ??? ??? HTTP ?? ? ??? ?? ? ? ????. ???? ???? ??? ??? ???? ?? ?? ? ?? ???? ??? ??? ???? ??? ???? ??? ?????. ??? ??, ?? ?? ??? ?? ??? ???? ??? ? ????.
?? ? ????? ??? ??? ?????? Slim?? ????? ?????
? ???? ???? ???? ?? ?????. ? ?????- ? ? ????
- ?? ? ?? ????? ????? ???? ??? ??????
???? ???? ?? ?? ????? ????? ?? ? ? ????. ? ??? ???? ???? ????? ?????. ????? ?? ???? ????? ????? ?? ? ????? ??? ????? ?????. MiddlewareInterface
?? ? ?? ??? ????? ??? ? ??????, ????? ?? ? ?? ??? ?? ? ? ????. ??? process()
?? ??ServerRequestInterface
???? ???? ???? ?????. ?? ?? ?? ???? ??? ??? ????? ?? ? ????.RequestHandlerInterface
process()
??? ????? ?? ?? ????? ?? ?? ? ? ??? ???? ??? ????? ?? ???? ?????. ?? ?? ?? ????? ?? ??? ?? ????? ??? ? ????. -
?? ? ?? ??? ???? ?? ????? ???? ??? ??????
???? ????? ??? ???? ????? ???? ?? ? ?? ??? ?? ? ? ????. ?? ?? ??? ???? ?? ??? ?? ?? ???? ?? ???? ???? ? ? ????. -
????? ???? ?? ? ???? ?? ? ? ????? ?, ????? ?? ?? ? ??? ?????. ?? ?????? ??? ?? ?? ??? ???? ?? ? ? ??? ???? ???? ?? ?? ?? ??? ?????.
?? ??? ?? ?? ? ??? ?? ??? ???? ????? ???? ??? ??? ? ????. ?? ?? ???? ??? ?? ????? ?? ?????. -
?? ? ?? ????? ??? ? ?????
?, Slim? ?? ????? ?????. ?? ?????? ?? ????? ?? ? ? ????. ?? ?? ?? ????? ???? ???? ??? ?? ? ? ????. - ? ?? ????? ????? ??? ??????
??? ?? ???? ????? ?? ?? ? ??? ???? ????? ???? ?? ?????. ?? ?? ?? ?? ?? ?? ?? ??? ??? ? ????? ???? ????? ?? ? ? ????.
?? ???? ??????. ???? ?? ? ??? ?? ? ??? ????.
? ??? PHP ??? | ?? ????? ?????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

? ?? PHP ??? ???? ?? ? ?? ????? ? ?? ?? ??? ????. 1. ??? ??? ?? ?? ??? ?? Array_Merge ? Array_unique ??? ??????. ?? Array_Merge ($ array1, $ array2)? ?? ? ?? Array_Unique ()? ???? ?? ?? ? ?? ???? ? ??? ?????. 2. ?? ?? ? ? ?? ???? ? ? ?? ????? ???? ??????. $ result = $ array1 $ array2? ? ?? ??? ?? ? ?? ??? ?? ?? ?? ??????. ? ? ?? ??? ? ??? ????? ??? ?? ?

????? ??? ????? ????? ??? ??? ???????. ?? ?? ??? ??? ????. 1. ??? 8 ?? ?????. 2. ??? ???, ??? ? ??? ?????. 3. ?? ?? ??? ?? ? ? ????. ?? ??? ????, ??? ???? ?? ? ??/?? ???? ?????, ?? PHP ?? ??? ?????. ???, ?????? ???? ?? ? 123456? ?? ???? ?? ??? ????????. ????? ?? ???? ????? ?? ZXCVBN ?????? ???? ?? ????.

PHP ?? ???? ???? ????? ?? ? ??? ???? ?? ?? ? ??? ???? ?? ??? ?????? ??? ??? ? ? ???????. 1. ??? ?? CSRF? ???? ?? ??? ??? ???? ?????? ??? ???? FINFO_FILE? ?? ?? MIME ??? ?????. 2. ??? ??? ??? ???? ??? ?? ??? ?? ? WEB ????? ??? ???? ??????. 3. PHP ?? ??? ?? ? ?? ???? NGINX/APACHE? ??? ????? ?? ???? ?????. 4. GD ?????? ??? ? ?? ???? ??? ?? ??? ?? ????.

PHP ?? ??? ?? ???? ?? ? ????? ??? ?????. 1. ?? ??? ??? ??? ??? ? ? ??? ??? ??? ?? ?? ??? ???? ???????. 2. ?? ??? ???? ???? ? ?? ????? ?? ?? ?? ??? ?????. 3. $ _get ? $ _post? ?? Hyperglobal ??? ?? ???? ?? ??? ? ??? ??? ??????? ???????. 4. ?? ?? ?? ???? ?? ?? ?? ??? ?????? ?? ??? ??? ?? ??? ???????. ??? ??? ????? ??? ??? ?? ???? ????? ? ??? ? ? ????.

PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

Ageneratorinphpisamemory- ???? Way-Erate-Overgedatasetsetsbaluesoneatimeatimeatimeatimallatonce.1.generatorsuseTheyieldKeywordTocroadtOpvaluesondemand, RetingMemoryUsage.2

PHP?? ??? ???? ? ?? ??? ???? : ?? () ??? ????? ???? ?????? []. 1. ?? () ??? ???? ?? ???? ???? ???? ?????. $ fruits = array ( "Apple", "Banana", "Orange")? ?? ??? ???? ???? $ user = array ( "name"=> "john", "age"=> 25)? ?? ?? ??; 2. [] ??? $ color? ?? PHP5.4 ??? ? ??? ?? ?????.
