If I were to say
echo $arr[some_index];
as opposed to saying
echo $arr['some_index'];
Will there be a significant amount of processor time/power lost to the error notice? I am aware that it is not proper syntax, but there is a huge amount of code written like this already on a project I am working on.
Well, it's simple enough to check. You can check the execution time on any statement(s) like such:
$start = microtime(true);
//Do your code. Try an echo of one kind here.
$end = microtime(true);
echo($end - $start); //The elapsed time, in seconds. Precise up to a microsecond.
Do one of those for each type you'd like to test. Whichever is consistently fastest will be the quickest, naturally.
You can also use memory_get_usage
to determine how much memory has been used, before and after each call.
Now, you should also be getting a large number of NOTICE
's. If a constant isn't defined, it's treated as a string instead, but throws a notice. Another problem is if your key ever conflicts with a constant, you'll be checking the wrong value. It's really just not good practice. I'd go through and replace everything.