There is this pogram at work, the one I described in an earlier post, that I created using PHP. Now, I’m a C/C++ programmer, so I could use PHP very easy, because it looks so much like C. It even behaves in a similair manner. There are differencess though. Like how you don’t need to allocate and free memory in PHP, or how a variable can contain anything. In PHP a variable has no type. I can assing a string to a variable and then later assing an integer or an array to the same variable. That’s also very handy. But, as it turns out, there are also other differences. Differences I didn’t know about and that caused bugs in my code.

Here are 3 differences that caused me a lot of headaches:

  1. A variable containing an empty array equals to boolean false.
  2. Using continue from a switch statement, works like a break and does NOT continue to for-loop the switch was in.
  3. Using unset() on a ‘pass-by-reference’-variable only destroys the local copy of that variable, even though ‘pass-by-reference’ means you don’t create a local copy.

All of these things are documented, I just assumed they worked like they would in C/C++. So it’s all my own fault.
Still sucks though.