开发者

Do too many Undefined Index or Undefined Variable errors effect server performance

As the notice is off in my php config it does not show notices in website. But i can see a lot o开发者_运维技巧f Undefined index /undefined variable in the server log/php log

Will this affect system performance by any chance.

If i decalre these variable and assign null to these , error will go. As it is defined.

Another doubt is , in some cases those variables will not be using.

So i declare and assign somany variable and if i am not using those variables . Will this affect the performance.


Nope.

None of your concerns are performance related.

Performance is not the only darn thing to care of.

I noticed some other questions of this kind recently (1),(2) and it's scaring me.
Because these questions lacks very basic thing: a sense.

Every thing in this world has not only it's cost but also it's sense.
And I'd say that sense is main reason to prefer one thing over another.

Say, there are 2 kinds of dishes, a heap, filthy and dirty one vs. clean, healthy and taste but more expensive one. Would you always prefer only cheap one, just because of it's cost? I doubt so.
Walking is great way to save a carfare. Do you always walk, no matter of the distance, obstacles and destination? Is cost being the only reason you're taking into account? I doubt so.
You're traveling by some vehicle sometimes, just because it's more reliable way in certain circumstances. So, you choose things my sense, not by cost.

Same here.
If you have some errors in your code, these errors should be your concern, not related performance. If you have your logs flooded with waste errors, obscuring real important ones, you have to turn these minor ones off. Not because of system's performance but because of programmer's performance, letting him get in touch with site heartbeat.

The sense, the meaning of the matter should be your concern. Not abstract "performance". There are languages apparently faster than PHP, say, assembly language for example. So, being concerned only in performance, you have to use assembly language only. But you choose PHP for it's reliability. So, be consistent, choose things by their sense, not imaginary(!) performance.

When you're asking about code structure, it's reliable code structure should be your concern, not imaginary performance issues. Isn't it obvious?


Will this affect system performance by any chance.

Yes.

But you should declare all variables and indexes before using them because the next time you misspell a variable name, you will notice the mistake immediately, instead of it getting lost in the noise.

The time you save tracking down such a silly bug can then be used to code something important, like a more optimized algorithm that will save even more time.

This indirect "system performance gain" is of more value than the direct saving.

So i declare and assign somany variable and if i am not using those variables . Will this affect the performance.

Failing to declare your variables doesn't change the number that you actually are using! Declare them at the appropriate place. Keep your scopes limited to the task at hand, and it will be easy to manage.


Logging always causes a small overhead and if you can avoid unneeded error logging with little work, why not do it? It won't affect system performance dramatically, but imho it's generally not desirable to clutter your log space with warnings for undefined variables.

If you fill your logs with stuff like this, the real errors will be much more difficult to spot.

Another doubt is , in some cases those variables will not be using.

Declare them as soon as you know that you need them. There is no need to have all your variables declared at the beginning of the script ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜