PHP is a jerky joke when it comes to writing standalone servers. A language like C++ is way more efficient for that kind of task, even through the pure web development may still use PHP.
However, sharing data between both languages means that in order to make a change, both versions have to be kept in sync.
Facebook has a nice answer to that: they embed the PHP interpreter in their C++ apps, as you would do with Lua. The C++ app just loads PHP files and then, PHP functions can be called almost as if they were C++ functions.
Facebook recently released a great BSD-licensed library that makes this task really trivial: PHPEmbed.