 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Court Ewing's Blog: Common, Cryptic PHP Errors
by Chris Cornutt May 01, 2012 @ 13:09:51
Court Ewing has a new post to his blog describing some of the most common cryptic errors that you might come across in your day-to-day development.
If you've been programming for awhile, then you've probably experienced your fair share of cryptic error messages. It's understandable that building in detailed error messages that are clear to even novice developers is not always a high priority for programming languages when there are so many other features to create and issues to address. The PHP language has decent error messages, but it is by no means an exception to this rule.
The three errors he covers are probably familiar to anyone that's been working with PHP for any length of time:
- Fatal error: Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
- Fatal error: Can't use function return value in write context
- Fatal error: Exception thrown without a stack frame in Unknown on line 0
voice your opinion now!
common cryptic error message language
Justin Carmony's Blog: PHP, Sessions, __sleep, and Exceptions
by Chris Cornutt March 27, 2012 @ 12:25:02
Justin Carmony has a recent post to his blog about a problem he came across where his exception was being thrown with a line number of zero - cause for some investigation.
Today I ran into a problem where my PHP Application would throw this fatal error: "Fatal error: Exception thrown without a stack frame in Unknown on line 0". Which is so much fun, because it doesn't have a line number, so I had no direction as to what exactly was causing the problem.
He found a blog post that helped him track down the issue that, as it turns out, with serializing objects into the session and an error in the __sleep method.
voice your opinion now!
exception problem sleep serialization error handler
PHPMaster.com: Error Logging with MongoDB and Analog
by Chris Cornutt March 22, 2012 @ 11:11:39
On PHPMaster.com today there's a new tutorial from Lorna Mitchell introducing you to using Analog for error logging in a MongoDb connection. Because of the way the tool (Analog) is designed, it could be used anywhere - she just uses the MongoDB connection as an example because it integrates easily and efficiently.
MongoDB is an excellent fit for logging (and of course other things as well) for many reasons. For one, it is very VERY fast for writing data. It can perform writes asynchronously; your application wont hang because your logging routines are blocked. This allows you to centralize your logs which makes it easier to querying against them to find issues. Also, its query interface is easy to work with and is very flexible. You can query against any of the field names or perform aggregate functions either with map/reduce or MongoDB 2.2's upcoming aggregation framework.
This article will show how you can use existing code to add a logging library to your code and log errors to MongoDB. You'll also see how to query MongoDB from the command line and how to filter those queries to find the information you are interested in.
Analog makes it simple to log information in an easy to use, self-contained, extensible kind of way, offering writers for multiple output formats including: files, the FirePHP plugin output, email, POSTing to another machine and sending to a syslog daemon. She also mentions the different logging levels the tool makes available and how to filter down your logging results based on them (searched by "equal to", "greater than" and grouped by level).
voice your opinion now!
error logging mongodb analog document database tutorial
PHPBuilder.com: Error Handling in PHP 5
by Chris Cornutt March 07, 2012 @ 13:37:12
New on PHPBuilder.com today Leidago Noabeb gives you a pretty comprehensive overview of error handling in PHP - everything from the types of errors to how to control which are output in which environments.
In this article we will be looking at how to handle errors in PHP. Errors are an inevitable part of software development, and accordingly, we will be looking at the various error types and demonstrating how to handle them. If you intend to run any of the sample scripts in this article, please make sure that display errors is turned on in your PHP initialization document (php.ini).
The article talks about the types of errors PHP uses (syntactical, runtime and logical) and shows how to handle some of the most common issues with them. It also talks about the different error reporting levels (ex. E_ALL, E_WARNING, E_STRICT) and includes the code for a simple error handler class that switches off and handles each type differently.
voice your opinion now!
error handling class example levels tutorial
Nikita Popov's Blog: htmlspecialchars() improvements in PHP 5.4
by Chris Cornutt January 30, 2012 @ 09:55:24
In this new post to his blog Nikita Popov looks at an update that might have gotten lost in the shuffle of new features coming in PHP 5.4 - some updates to htmlspecialchars.
One set of changes that I think is particularly important was largely overlooked: For PHP 5.4 cataphract (Artefacto on StackOverflow) heroically rewrote large parts of htmlspecialchars thus fixing various quirks and adding some really nice new features. Here a quick summary of the most important changes: UTF-8 as the default charset, improved error handling (ENT_SUBSTITUTE) and Doctype handling (ENT_HTML401,...).
He goes into each of these three main features in a bit more detail, providing code to illustrate the improved error handling and the new flags for Doctype handling (covering HTML 4.01, HTML 5, XML 1 and XHTML).
voice your opinion now!
htmlspecialchars improvement release doctype error utf8
Brian Moon's Blog: Errors when adding/subtracing dates using seconds
by Chris Cornutt January 17, 2012 @ 11:19:22
Brian Moon has a reminder about date handling in PHP - days are not always 86400 seconds long, sometimes there's "leap seconds" included too. Thankfully, there's easy ways around it:
The problem with this is that it assume that there are only 86400 seconds in every day. There are in fact not. On days when the clocks change for daylight savings time, there are either 1 hour more than that or 1 hour less than that. In addition, there are also leap seconds put into our time system to keep us in line with the sun. There is one this year, 2012, on June 30th in fact. Since they don't happen with the regularity that daylight savings time does, it may be easy to forget those. Luckily, for this problem, the solution is the same.
His first solution involves letting strtotime do the work for him, internally calculating the leap seconds or any other issue that might come up. As an alternate solution, he also mentions "doing your math at noon" - this gives you enough leeway to make the offset leap seconds could cause a much smaller risk.
voice your opinion now!
error add subtract date seconds strtotime noon
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
Lorna Mitchell's Blog: Handling SQL Errors in PDO
by Chris Cornutt November 16, 2011 @ 09:43:34
Lorna Mitchell has a quick new post showing one way to handle SQL errors in PDO that could pop up because of badly written/generated SQL statements.
I love PHP's PDO (PHP Data Objects) extension; it gives a consistent, object-oriented interface to handling all kinds of relational database backends. One thing that annoys me is that the MySQL driver for PDO defaults to a silent error mode which can make SQL errors tricky to spot!
In her two code snippets she shows a failing PDO request (that fails silently) and a method for catching this issue - checking the result of the "errorCode" method to see if it equals "0" (zero). If there were errors, you can use the "errorInfo" function to get to them. This will return the SQL error code, the driver-specific error code and a driver-specific error message.
voice your opinion now!
pdo error handling errorcode errorinfo tutorial
PHPMaster.com: Error Handling in PHP
by Chris Cornutt November 10, 2011 @ 08:41:39
On PHPMaster.com today there's a new tutorial from Sneha Heda looking at error handling in PHP - the types of errors that can come up, how to throw your own and how to catch them appropriately.
Errors are the most common event a developer faces when programming. [...] To help reduce the number of errors in your code, and to mitigate their effects, proper error handling is essential in your web application. This article is a crash course in PHP error handling. You'll learn about PHP's built-in error reporting levels, and how to handle errors with custom error handlers and exception handling.
She starts with the different error reporting levels PHP offers, everything from the lightweight E_NOTICE out to E_ALL|E_STRICT. With this as a reference, she shows how to create a custom error handler (using set_error_handler). Also included is a look at exceptions and some of the more detailed information that comes with them - line numbers, messages, file the error was thrown from, etc.
voice your opinion now!
error handling tutorial exception custom handler reporting level
Ian Barber's Blog: Linear Regression in PHP
by Chris Cornutt October 13, 2011 @ 12:57:09
Ian Barber has a new post about an interesting method for determining the "line" that results follow in your statistics - linear regression in PHP (complete with code samples).
There are a lot of problems that fall under predicting these types of continuous values based on limited inputs - for example: given the air pressure, how much rain will there be, given the qualifying times, how quick will the fastest lap be in the race. By taking a bunch of existing data and fitting a line, we will be able to make a prediction easily - and often reasonably correctly.
He defines two pieces of information, the intercept and the gradient, and how they relate to minimize the "square error" that can come from getting the square root of your values based on the difference between an actual and predicted value. Based on a sample data set, he comes up with these results, showing the trend line for the points given. He points out a few issues with the method and corrects them with a few tweaks to his original algorithm.
voice your opinion now!
linear regression algorithm square error
|
Community Events
Don't see your event here? Let us know!
|