I do not quite get what's the distinction between Nginx and Apache?

I wish to use PHP Comet way of the chat. I actually do like this:

while($modification_date == filemtime($filename)) { 

//$filename was updated and we retrieve new messages and give them to the user with JSON help

It obviously does not operate in Apache. Does it operate in Nginx?

Don't offer me NodeJS along with other, please.

Primary distinction between Apache and Nginx is a is thread driven and the other is event driven. But, I believe your real question is not obvious. They've nothing related to your code snippet. And first explain why It'll not operate in Apache.

Nginx does not automagically make that code work. It'll suck just as bad because it did in Apache. The primary issue is that PHP is not threadsafe and every request needs one forked PHP proc to handle request. This means insanely considerable amounts of needed RAM to scale to anything of decent size. Nginx could possibly get for this problem with a different type of programming (comet) and the aid of an extension.