 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPMaster.com: Why Suppressing Notices is Wrong
by Chris Cornutt December 24, 2012 @ 13:35:30
On PHPMaster.com there's a new article that suggests that suppressing notices thrown from your code is a bad practice to get into, both through error reporting and the use of the suppression operator, "@".
The PHP notice suppression operator is somewhat of a controversial topic in many circles. Some overuse it, some don't use it at all, and some don't even know it exists. Apologies in advance for the horrible code you're about to witness in this article, but it serves a purpose to illustrate the usefulness (or lack thereof) of the suppression operator.
He talks about some of the common notices and how the suppression operator prevents the "Notice" message that could come out of it. They suggest, however, that there's never a good time to use the operator, especially during development. Obviously, there are a few cases (they point out one with mail) where it could be useful. There's also some sample code for a custom error handler you can use to capture the issues that might come up.
voice your opinion now!
error notice suppression development
Mark Story's Blog: New errors in PHP 5.4
by Chris Cornutt December 30, 2011 @ 08:30:45
In this quick new post to his blog Mark Story talks about two new errors he ran across when upgrading his installation to PHP 5.4, both showing up under E_ALL.
I've been running the PHP5.4 RC builds for the last few months, and there are some interesting changes in the upcoming PHP release. On top of all the great new features coming in PHP5.4. After updating to PHP5.4-RC4, a few things that used to not trigger errors and silently do the wrong thing, now trigger notices or warnings.
The two he mentions deal with a new warning on illegal string offsets and the other about string offsets ("Notice: String offset cast occurred"). You can find out about more changes in the PHP 5.4 series in the various Changelogs for each Release Candidate and beta release.
voice your opinion now!
new error update version warning notice offset string
Brandon Savage's Blog: Avoiding Notices When to Use isset() and empty()
by Chris Cornutt September 23, 2009 @ 08:47:13
If you've ever been bothered by those pesky NOTICEs when running your code, you know that you can wrap evaluations or check things with an empty or isset call to make them go away. Brandon Savage has a new post that can help you decide which one to use when, though.
As developers, we want to develop code that never emits notices or warnings, and PHP gets a bit antsy when we develop code that utilizes uninitialized variables. Lucky for us, PHP makes it easy to test for these variables without getting these notices. [...] PHP (like most languages) evaluates a logical argument left to right. For an AND condition, both conditions have to be true; PHP stops evaluating if it finds any condition untrue.
He suggests that the case to use isset() is more when you just want to use another check in the conditional but don't want to be bothered if the variable isn't there. A call to empty(), however, also evaluates the contents of the variable if it exists. Be careful, though - empty() returns false if the value of the variable is false - so take care in your use and always test scripts with multiple values.
voice your opinion now!
avoid notice tutorial isset empty
Brandon Savage's Blog: Scaling Up Reducing Drag, Increasing Lift
by Chris Cornutt February 24, 2009 @ 15:13:15
Brandon Savage has posted the next article in his "Scaling Up" series, a look at reducing the amount of "drag" your application makes through its processing path and some tips to help increase its "lift" out of some common problems.
The intuitive will note that many if not most of these suggestions are performance enhancements, not scaling techniques. Why then are they in an series about scaling? Scaling is about more than just adding hardware. It's also about making sure your system runs better. You can add lots and lots of hardware but you will someday be unable to compensate for bad queries and poor optimization.
Some of his suggestions include taking care of any sort of errors or notices (anything that could slow the script down by writing to a log), defining virtual hosts instead of making excessive use of .htaccess files and installing caching software to maximize code and information reuse.
voice your opinion now!
scale lift drag tip error notice cache htaccess optimize sql concurrency
PHPFreaks.com: Debugging A Beginner's guide
by Chris Cornutt June 10, 2008 @ 07:59:13
On PHPFreaks.com there's a new tutorial providing a beginner's guide to debugging in PHP (with the built in functionality PHP has, not external software).
Everyday the forums see probably hundreds of topics posted where the problem is a fairly simple error. [...] As a beginner, it can be difficult to find and solve these errors. By tackling each of these in turn, I hope to teach you some methods of finding and solving them.
They look at the different sorts of errors - syntax errors, fatal errors, warnings, notices - as well as some of the ones a bit harder to track down like database problems and logical errors.
voice your opinion now!
debug beginner guide parse warning fatal error notice
Ivo Jansch's Blog: System.out.print in PHP
by Chris Cornutt March 09, 2007 @ 07:12:44
Ivo Jansch discovered something interesting by way of an applicant's resume - a hidden "trick" that PHP pulls on the user when they try to use a Java-like syntax with System.
So yesterday I was reviewing a code sample that a job applicant had written during a test and I encountered the following line of code: It's not hard to guess what his background was :), but I was initially stunned that this actually works in php.
After a little investigating (and ruling out the Java Bridge), Ivo found that the line was being interpreted literally and was just being handled as a string instead of a constant. He gives two other examples to help with clarification.
voice your opinion now!
constant string java bridge notice constant string java bridge notice
Justin's Blog: Debugging Php
by Chris Cornutt February 09, 2006 @ 07:22:32
On his blog, Justin has posted an article from David Sklar today - a look at PHP error reporting - conifguration, locating errors, and checking variable values as the script runs.
Whether you're a PHP newbie or a wizard, your programs are going to have bugs in them. Nobody's perfect.
This article gives you some techniques for finding and fixing the problems in your programs. It covers three topics: how to get the PHP interpreter to report the errors that interest you, how to locate basic syntax errors in your program, How to check the values of variables as your program is running.
The configuration section mentions the display_errors and log_errors options to help debug your scripts. There's also a bit describing what the different error types mean (parse, fatal, strict) and simple things to look for to handle them. He also suggests some other resources to look at to help with more detailed error reporting...
voice your opinion now!
debugging error reporting types common parse fatal notice debugging error reporting types common parse fatal notice
|
Community Events
Don't see your event here? Let us know!
|