4 ms·
> I've written PHP for about 3 years and I've never once used the @ to suppress errors. Is it so wrong to use @? I've always used (@$_REQUEST['foo'] === 'bar')
by Zarel 15y ago
> I've written PHP for about 3 years and I've never once used the @ to suppress errors.
Is it so wrong to use @? I've always used (@$_REQUEST['foo'] === 'bar') as a shorter way of writing (isset($_REQUEST['foo']) && $_REQUEST['foo'] === 'bar') - I'm curious if there's a problem with that approach.
- wvenable 15y agoActually yes because the error gets generated anyway (and that is slow) and then it's just suppressed at the last moment. You'd probably be better off creating a function to do what you want succinctly rather than using the suppression operator.
- brendoncrawford 15y agoYou be using array_key_exists instead.