Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Error Suppression Operator (@) as a shortcut for isset(). Bad Practice? [closed]
- if ( isset($_SESSION) && isset($_SESSION['myVariable']) && $_SESSION['myVariable'] == true )
- echo "myVariable is True!";
- if ( @$_SESSION['myVariable'] == true )
- echo "myVariable is True!";
- session_start();
- $count = 0;
- $start = microtime(true);
- for($i=0;$i<10000;$i++){
- if ( @$_SESSION['myVariable'] == true ){
- $count++;
- }
- }
- echo "Took ".(microtime(true)-$start)." Microseconds with error supression.<br />";
- $count = 0;
- $start = microtime(true);
- for($i=0;$i<10000;$i++){
- if ( isset($_SESSION) && isset($_SESSION['myVariable']) && $_SESSION['myVariable'] == true ){
- $count++;
- }
- }
- echo "Took ".(microtime(true)-$start)." Microseconds with formal checks.<br />";
- Took 0.010571002960205 Microseconds with error supression.
- Took 0.002446174621582 Microseconds with formal checks.
- Took 0.0098469257354736 Microseconds with error supression.
- Took 0.00094795227050781 Microseconds with formal checks.
- if (!@chmod($someFileUri)) {
- throw new Exception('Cannot change mode plus some extra stuff...');
- }
Advertisement
Add Comment
Please, Sign In to add comment