

There are days when I want to quit using php... - jacquesm

Seriously. Just wasted an hour on this:<p><pre><code>  &#60;?php

  $s = "title";
  $k = 0;

  if ($k == $s) {
    echo("this is bad!\n");
  }
  else {
        echo("this is good\n");
  }
</code></pre>
I realize my mistake now ($k being an integer and $s being a string, PHP converts both to integers implicitly and does the comparison) so I would have had to use the === instead but I read over that missing = for a long time...<p>The problem is that this was not new code.<p>It worked flawlessly until one day an array key was made that was not a string but an integer, and by sheer coincidence that integer was 0.<p>The foreach loop surrounding the code did not check the type of the array keys...
======
ihumanable
If the above is the only reason to quit PHP I would advise against doing it.
This is a rather small issue, you could switch to other languages and have any
number of small issues. Oh, somebody monkeypatched this built-in function,
should have used .equals() instead of ==, so on and so forth.

There are plenty of good reasons to switch to a different language, but in
this case I would highly suggest holding out for something a little more
extreme.

Although as an avid PHP devloper who has chased down his fair share of
coercion errors, I feel your pain.

~~~
jacquesm
Don't worry, I'll feel better tomorrow. And thanks for the sympathy, it's just
that it took a long time (much too long) find this one.

Last time I had to look this hard at least I was satisfied with being able to
file a bug report with the php folks. This time I can only blame myself.

------
balding_n_tired
My proposed motto for PHP: putting the "antic" in "semantics". Have a look at
the values of

max('1', '3', '10')

max('1', '3 ', '10')

max('1', '3 ', 10)

and better still

max('antelope', 'wombat', 1, 3, 10)

max('antelope', 'wombat', '1', '3','10')

Not at any step necessarily unreasonable decisions, but not (to my eye)
obvious ones.

------
davidw
So do it; there are plenty of good alternatives. The only thing I'd keep PHP
for is for adding just a dash of "dynamicity" (dynamicness?) to mostly static
pages.

~~~
jacquesm
I'd have to convert the production of a team of people over about a decade to
something else... If it weren't for the huge installed codebase I have I
probably would.

The drawback of having an investment in anything at all is that it gets harder
to switch away from it.

~~~
davidw
Yep, tough problem. Start with small, peripheral projects, and find a way to
make the code talk to the old code? That's about as good as it gets... not
easy.

