Comments on: My list of PHP language features with hard-to-imagine-use-cases: #1 – The @ symbol that supresses errors http://www.aschroder.com/2008/11/my-list-of-php-language-features-with-hard-to-imagine-use-cases-1-the-symbol-that-supresses-errors/ Notes on Web Development Wed, 23 Dec 2020 09:25:05 +0000 hourly 1 https://wordpress.org/?v=4.8.15 By: Ashley http://www.aschroder.com/2008/11/my-list-of-php-language-features-with-hard-to-imagine-use-cases-1-the-symbol-that-supresses-errors/comment-page-1/#comment-2313 Tue, 17 May 2011 22:10:02 +0000 http://www.aschroder.com/?p=8#comment-2313 Very old indeed! But you’re right, plus I’m not so scathing of PHP these days – still prefer Java though 🙂

]]>
By: Lee Saferite http://www.aschroder.com/2008/11/my-list-of-php-language-features-with-hard-to-imagine-use-cases-1-the-symbol-that-supresses-errors/comment-page-1/#comment-2309 Tue, 17 May 2011 10:13:05 +0000 http://www.aschroder.com/?p=8#comment-2309 I know this is a REALLY old post, but I thought I’d point out one thing. While the usage of @ is bad, it’s not as simple as replacing usages of it with a try/catch block.

The @ is supressing PHP error messages which are not the same as exceptions. You can register an error handler that can throw exceptions, which is what Magento does, but it’s not standard.

Any usage of the @ should include good error checking at the very least. In reality it should prompt a mental refactoring of what you are doing.

]]>
By: Ashley http://www.aschroder.com/2008/11/my-list-of-php-language-features-with-hard-to-imagine-use-cases-1-the-symbol-that-supresses-errors/comment-page-1/#comment-1422 Fri, 11 Jun 2010 22:56:16 +0000 http://www.aschroder.com/?p=8#comment-1422 Thanks for the insightful comment Chris – it’s easy to forget PHP has a long history and evolution to it’s current state. Ironically I’ve worked with it so long now, the coding in Java feels cumbersome (safe, but cumbersome).

Perhaps the answer is a newer differently designed scripting language like ruby, all the benefits of simplicity and a modern OO architecture.

(according to wikipedia, both came about around the same time – who knew…)

]]>
By: Chris Cox http://www.aschroder.com/2008/11/my-list-of-php-language-features-with-hard-to-imagine-use-cases-1-the-symbol-that-supresses-errors/comment-page-1/#comment-1421 Fri, 11 Jun 2010 15:46:59 +0000 http://www.aschroder.com/?p=8#comment-1421 Hi Ashley,

I appreciate that this is a very old post, but I thought I’d throw in a clarification for the sake of other folks like me who might stumble across this. PHP wasn’t developed as an OO language so I can see how it might not have made sense to someone with a Java background.

PHP has grown more or less organically from a simple procedural language and, apart from a very limited attempt to introduce OO constructs in PHP4, it wasn’t until PHP5 that most of the things you take for granted appeared. Older language constructs are very slow to be deprecated for reasons of backward compatibility.

So from the viewpoint of writing a simple script on a webpage (which is PHP’s origins) being able to suppress error messages is a good thing. Of course, now we have proper exception handling and all manner of other goodies the @ is a bit vestigial.

]]>