The following code generates a notice if $n is not set. Solving it requires an additional statement [isset[$n]
] or to "declare" the $n [$n=''
]. But what consequences does this notice have? The below code is a lot neater and lets say we turn error_reporing off in production no difference is visible frontend. Does something
bad follows? Prestanda, readability etc? [sorry for the bad english]
if[$n==1]{
//do something
}
asked May 7, 2011 at 12:19
There is no "consequence" to notices, per sé, other than bad coding practices. You should be coding with error_reporting set to E_ALL
on your development machines, so obviously the consequence there is a lot of notices...
I would argue that your code actually isn't neat, because you're testing a variable which doesn't get set previously.
A suggestion would be something like this: