One of the examples is a PHP Exam. I managed to score only 7 out of 12. A list of my errors in in the extended section of this article.
Sunday, September 25, 2005
Tuesday, September 20, 2005
After discovering about the debug_backtrace function (PHP >= 4.3.0); I was thinking about how wonderful it would be to attach a customized error handler to Nucleus when running in debug mode. This handler could output a stacktrace, which would be much more helpful than a message a la
"Tried to call a method on a non-object at code.php line x" when this line of code is buried deep into the code.
Unfortunately -- as I discovered the hard way -- the error handler function that is passed to set_error_handler is never called for fatal errors. This behavior is listed in the manual, but I only bothered to read it carefully once things didn't quite work as expected. The reason why these fatal errors cannot be trapped is that the engine might not be in a stable state. Bummer. An extra class of errors (fatal unless trapped) would certainly be welcome.
Sunday, September 18, 2005
In this article, I'm re-creating the example from the Friendly Forms post using HTML_QuickForm (a PEAR package) and the Smarty template engine. I'm also looking into how to easily distribute PEAR with your application.
Monday, June 06, 2005
Remember the What's wrong with this code? post from a week ago?
Niels catched most of the problems that I injected in the code. Allow me to describe the problems a little more detailed:
Sunday, May 29, 2005
Here's a challenge: I have a piece of PHP code, and it's up to you to find the possible issues with it. Security issues, code issues as well as issues with different PHP configurations and versions. Look at the code from the Nucleus perspective: a PHP script which will be installed on many different systems (for Nucleus: PHP versions 4.0.6 and up), and should run out of the box.
Solutions can be found in a follow-up post.
Friday, February 11, 2005
Note that at the time of writing, the current PHP version was 4.0.3, so it might be slightly outdated.
Tuesday, August 31, 2004
When using the
echo "function" to output a string which is combined of multiple parts, once could write:
echo 'foo' . htmlspecialvars($someVar) . 'bar'
The problem with this is that PHP will first concatenate the three strings (two concatenations) before using
echo to dump it to the output. This means that two extra string objects will be created into memory.
The alternative is using comma's. It looks a little weird, but
echo then behaves as a function that is taking multiple parameters and dumping all of them:
echo 'foo' , htmlspecialvars($someVar) , 'bar'
In this case, no concatenation is needed which means this code should be faster and more memory-efficient than the concatenating version.
I know the effect of this will be very limited, but I try to use this wherever I can.
Monday, August 16, 2004
In order to understand some parts of the Nucleus core code, you need to know what references are, how they work, and how to use them. This article tries to explain the basics of references. If you're familiar with programming languages like C or C++, this will look trivial. But remember: PHP references are NOT the same as pointers in C, they're more like symbol table aliasses.
Knowing how references work will help you understand the Nucleus
MANAGER class and the Nucleus Plugin API.
Monday, August 09, 2004
On the PHP website, there's a list of backwards incompatible changes made in PHP5. There's not much to worry about: apart from the fixes already applied to Nucleus, there are no new issues.
Monday, August 02, 2004
In order to make sure Nucleus runs on as much servers as possible, my PHP setup (
php.ini) is set up in a way to make the environment as hard as possible to work with. TeRanEX requested an overview, so here it is: