[SOLVED] Is Using @$_REQUEST A Good Idea?
Posted: Mon Aug 16, 2010 12:43 pm
Hello, world!
Having a chunk of code that looks like this to check every post/get field is annoying.
All that code just to depress an Undefined Index Notice. I know @$_POST['somefield'] works, but is it a good idea? What is the best way to do this?
Having a chunk of code that looks like this to check every post/get field is annoying.
Code: Select all
if (isset($_POST['somefield'])) {
$somefield = $_POST['somefield'];
} else {
$somefield = '';
}
// or maybe this
$somefield = isset($_POST['somefield']) ? $_POST['somefield'] : '';
// or maybe this
function _POST($field) {
return isset($_POST[$field]) ? $_POST[$field] : '';
}
$somefield = _POST('somefield');