Which of these code will be faster?
$temp = $_REQUEST['s'];
or
if (isset($_GET['s'])) {
$temp = $_GET['s'];
}
else {
$temp = $_POST['s'];
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
$_REQUEST, by default, contains the contents of$_GET,$_POSTand$_COOKIE.But it’s only a default, which depends on
variables_order; and not sure you want to work with cookies.If I had to choose, I would probably not use
$_REQUEST, and I would choose$_GETor$_POST— depending on what my application should do (i.e. one or the other, but not both) : generally speaking :$_GETwhen someone is requesting data from your application.$_POSTwhen someone is pushing (inserting or updating ; or deleting) data to your application.Either way, there will not be much of a difference about performances : the difference will be negligible, compared to what the rest of your script will do.