下面thinkphp框架教學欄位將介紹Thinkphp5.0.x指令怎麼執行filter,希望對需要的朋友有幫助!
Thinkphp5.0.x指令執行
同樣是利用<span style="color:#c7254e;">call_user_func()</span>
進行指令執行,在Request類的函數filterValue中執行【推薦:thinkphp影片教學】
先搜尋哪些函數呼叫了filterValue:
$request = is_null($request) ? Request::##instance #() : $request;#會執行request的建構函數,此時已經透過建構函式中file_get_contents('php: //input')取得了POST的內容並賦值給$request->input變數
Step2
#$dispatch
= self::routeCheck##($request, $config);
在routeCheck中會進入Route類別的check函數:
#check函數呼叫了$request->method():
#以下利用過程需要:debug模式開啟
跟進param函數:
/**
* 取得目前要求的參數
* @access public
* @param string|array $name預設值
* @param string|array $filter 篩選方法
* @return mixed
*/
先進入if條件,跟進method方法
method()傳入參數為true:
執行下列語句:取得原始請求類型
$_SERVER['REQUEST_METHOD'],傳回值為POST
回到param中,$ method=POST
因此會執行switch中的POST部分,進入post函數:
post函數:
/ **
* 設定取得POST參數
* @access public
* @param string
* @param string|array $filter 濾波方法
* @return mixed
*/
傳入參數:param()函數中:
$this->post##(false);進入getFilter:
getFilter中$filter = $filter ?: $this-> filter;取得到$request類別的filter變數值(先前在construct遍歷覆寫的),並作為傳回值給input函數
繼續執行array_walk_recursive($data, [$this# , 'filterValue'], #$filter)
;array_walk_recursive()
函數對陣列中的每個元素套用使用者自訂函數。在函數中,陣列的鍵名和鍵值是參數相當於$filters=system取$ data中的每一個變數以$value傳入,當取到ccc=ipconfig時, system作為call_user_func#第一個參數,ipconfig
作為第二個,造成了命令執行。
### ###
以上是說說TP5.0.x指令是如何執行filter的!的詳細內容。更多資訊請關注PHP中文網其他相關文章!