Search code examples
phpbenchmarkingerror-reportingvariable-assignment

PHP Benchmarking - checking for unset variables or warnings off


Does anyone know of the advantages disadvantages e.g. speed for checking to see if a variable is set rather than simply turning off warnings?

below is very bad example but illustrates what I mean:

#Does a check for the variable - error reporting on (Display no warnings)
$i = (!isset($i)) ? $i + 5 : 5;

#error reporting off (Display no warnings)
$i = $i + 5;

Thanks in advance for any thoughts!


Solution

  • This boils down to a fundamental issue: is it more important for your application to run correctly, or to run quickly?

    If you simply ignore warnings, logical errors may be overlooked. Your program may execute quickly, but the fastest faulty application has less value than the slowest functional one.