PHP optimization tricks

Here’s an article I came accross with some interesting PHP optimization tricks. I found the last one, about faster array access, particularly interesting/surprising.

4 Responses to “PHP optimization tricks”


  1. 1 josh

    My favorite trick is to use perl instead - seriously, I’m currently looking for a really cheap place to host the spamgourmet bbs, because I’m afraid to install PHP on the new server. A little tricky, because the really cheap ones (like godaddy) seem to want to hardcode the host name to start with www (instead of bbs, like I’d like)

  2. 2 John

    ha! you josh, are a perl brat.

    are you afraid to install it on the new server because of performance, or security?

  3. 3 Jeff

    Careful with the in_array / isset swap. I just tried it out on some of my code and found that isset did not correctly work like how in_array does. I couldn’t find the problem in the PHP docs. Just make sure to test it 1st.

    Even if it worked, however, I’m torn about writing speed-tuned code. PHP should really take care of this for me. Same thing with most of the speed tricks.

    APART from all that, however, if I was really hell-bent on speed, I wouldn’t be using these nice OO designs and abstraction layers. If I need speed, it’s less cost-effective to tune my apps (potentially lowering readability and perhaps breaking later if the assumptions about the language internals are no longer valid) than just hosting on a faster setup.

    I’m hungry.

  4. 4 sanjuro

    Good article, I learnt a couple of things. The isset / in_array trick works very well, however you have to keep in mind one uses keys and the other values.

Leave a Reply




Close
Powered by ShareThis