As you know, the @
characters before a php istruction suppress every eventual warning, error or notice from being raised.
Personally, i dont like this tecnique, becose i prefer to handle those errors, and in a real life, the error must no happen or have to be managed.
By the way, i find this tecnique to be applied in many scripts (cms plugins, open-source classes).
So, could the @ really be useful (in this case, an example would be appreciated), or is just for lazy developers?
Answer: material become useful when it is used in limit but fan material is used in excess it is harmful for both humans and environment.
Useful material - Material that still has or retains useful properties including materials that can be reused, recyclables, organics that can be composted, materials used for making fuel, material used for construction or land reclamation, and material used productively in the operation of a landfill.
These substances could be dusts, gases or fumes that you breathe in, or liquids, gels or powders that come into contact with your eyes or skin. There could also be harmful micro-organisms present that can cause infection, an allergic reaction or are toxic.
Just think of, for example, a failed mysql_connect
call. You may want to suppress the error message otherwise shown to the user (also showing some details you usually don't want anybody else to see) in this case.
Though the PHP warning was suppressed via the @
-sign, you can perform certain actions like showing a friendly error message to the user afterwards.
However "misusing" @
for things like in the example below is definitely not a good idea:
@$undefinedVariable .= 'some text';
There are far more examples for bad use of the error-suppression sign out there than the one above, you should only use it when there is no other, better way to achieve what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With