Among $_REQUEST, $_GET and $_POST which one is the fastest?

后端 未结 15 2232
小鲜肉
小鲜肉 2020-11-22 05:04

Which of these code will be faster?

$temp = $_REQUEST[\'s\'];

or

if (isset($_GET[\'s\'])) {
  $temp = $_GET[\'s\'];
}
else          


        
15条回答
  •  [愿得一人]
    2020-11-22 05:35

    I use this,

    $request = (count($_REQUEST) > 1)?$_REQUEST:$_GET;
    

    the statement validates if $_REQUEST has more than one parameter (the first parameter in $_REQUEST will be the request uri which can be used when needed, some PHP packages wont return $_GET so check if its more than 1 go for $_GET, By default, it will be $_POST.

提交回复
热议问题