You are viewing shlomif

Previous Entry | Next Entry


PHP's "? :" Operator

After staring at a bug at work for a while, and not understanding what I did wrong, I discovered the following: as opposed to Perl or C, PHP's condition operator "?:" is left-associative instead of right associative.

This means that the following expression:

$a ? $b : $c ? $d : $e

is equivalent in PHP to:

($a ? $b : $c) ? $d : $e

instead of the Perl/C (and more useful) version:

$a ? $b : ($c ? $d : $e)

If you want the latter semantics, you need to add parenthesis. Here's some More information about it.

In Search of the Best PHP Development Environment

After I started working on PHP for work, I wondered if there's a better development environment for it than Vim which I'm using for almost anything.

The first thing I looked at was Quanta Plus. Its HTML mode is pretty nifty, with ability to auto-complete tags, and to automatically put ending tags. Its PHP mode is also quite nice. However, it seems that a split view of the window is unavailable. (Which is strange, because the so-called Kate - KDE's Advanced Text Editor, does.) Since I often want to look at old code in the file or in a different one when writing new code, this has ruled it out for me.

Next I looked at PHPEclipse. This time I was able to find out how to have a split view there (in Eclipse). One problem I had with it was that it felt sluggish - the scrolling was slow, and typing characters into the edit window was slow. I was using the Fedora Core 5 Eclipse packages, on an Athlon 64 machine with 2 GB of RAM (in 32-bit mode), which is a high-end machine, but it still felt sluggish.

Another problem I had was that it messed my tabs/spaces indentation (but I suppose that's configurable somewhere), and that it kept asking to save one of the files under a different name when I switched to its tab. It also had something else that disturbed me but I can't quite recall what.

So it seems that gvim, even though not ideal is the best of what I tried, and so I'm sticking with it. If you know of another alternative, please let me know and I'll try it.


Latest Month

September 2013


Powered by
Designed by Tiffany Chow