Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
下面的函数在PHP中有什么用途?_Php - Fatal编程技术网

下面的函数在PHP中有什么用途?

下面的函数在PHP中有什么用途?,php,Php,这个函数在PHP中有什么用途 public function processApi() { $func = strtolower(trim(str_replace("/","",$_REQUEST['rquest']))); ( (int)method_exists($this,$func) > 0 ) ? $this->$func() : $this->response('',404); // If the method not exist with

这个函数在PHP中有什么用途

public function processApi()

{

 $func = strtolower(trim(str_replace("/","",$_REQUEST['rquest'])));

   ( (int)method_exists($this,$func) > 0 ) ? $this->$func() : $this->response('',404); 

   // If the method not exist with in this class, response would be "Page not found".

}

$\u请求
包含
$\u GET、$\u POST和$\u COOKIE的内容。

因此,基本上您正在读取从客户机传递的方法名,并检查它是否存在于特定的上下文/类中

如果函数存在,则代码正在执行该函数,如果未找到,则返回404


但是,这很容易受到攻击,因为它公开了方法,任何用户都可以远程调用这些方法

如果函数存在于同一类中,请运行它或显示404页。非常脆弱。谢谢你的友好和有用的回复