Does PHP have a virtual machine like Java?
Yes.
Independently from the platform PHP is running on, the scripts are compiled into the same bytecode and run by the Zend Engine.
The difference from Java is that this compiled code is usually not stored into separate files and the scripts are re-compiled on each execution (however, see opcode caches).
Another important difference between the Zend Engine and a typical JVM is in the way they execute bytecodes:
The Zend Engine executes (interprets) the compiled bytecodes directly. (At least that’s what I think happens.)
A JVM will normally use a JIT compiler to compile bytecodes to native instructions, and then execute the native instructions.
Actually, JVM behaviour is more complicated than this. JVMs don’t always compile to native code, and when they do, they typically delay JIT compilation until they figure it is worth doing. Prior to that, they execute the bytecodes directly.