
Untitled
By: a guest on
Apr 26th, 2012 | syntax:
None | size: 1.11 KB | hits: 12 | expires: Never
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...');
}