When I fill variables, can I do something like this?:
$type = isset( $_GET['type'] ) ? $_GET['type'] : die();
By doing so, if ‘type’ is not in the request, my function will exit. Is this the correct way to use die()?
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.
If you just want your function to exit, use
return. However, it’s not an expression, so you’ll need to change it to anifstatement:If you do want your whole page to stop execution, then yes, that’s correct (but I’d still use an
iffor clarity).