PHP Data Type Mismatch Crashes CodeIgniter!

September 21, 2013

Learn PHP by Building Web Applications


It’s been a long while since I’ve blogged about anything here … been busy building things.

Refactoring a Prototype

Recently, we were refactoring a PHP/CodeIgniter based project, cleaning up the code from a quick prototype we put out. When you have an idea for a piece of software, it is almost always a good tactic to first put out a rough prototype, to see if it has any legs … will anyone find use in your brilliant new idea?

Get user Feedback ASAP!

Another advantage of quick prototyping, is that you can use user feedback to finetune your app to their needs. I became much more successful as a developer doing things this way, over building a rock solid app from the start. Users will always find flaws in your original ideas and many of your ideas will simply not work … so it’s best to get the app into peoples hands as soon as you can.

CodeIgniter Barfs!

In the process of refactoring the app, we moved things out of session and into a database (mySQL) to keep track of what users were doing. Session should only be used sparingly … and there are a few reasons why (session collision, scalability of the app) … but it is convenient for prototyping.

.. Anyway, while doing this we found (what I think) is a major flaw in CodeIgniter’s error trapping capabilities: a simple type mismatch in a function/method call caused CodeIgniter to barf and a generic server error was spit up to the screen!


Sadly, this reminds me of the classic ASP ‘unspecified error’ we used to get back in the 1990’s. These are useless errors that tell you nothing about what’s going on … except that there is an error.

Fortunately, we were able to step through the PHP code and found that we were trying to pass an array, where the method wanted a custom object. My point is that codeIgniter should have been able to handle this error and given us (at least) a somewhat useful/informative error.

At this time, we like the Laravel framework better.


Stefan Mischook


Comments are closed.

To Top