You are probably a victim of the bootloader timeout.
Opening the serial port resets the arduino. There is a two second period after you open the port from PHP during which your program is not yet running. If you send data during this window, the bootloader eats it.
In the PHP code it appears you write to the serial port immediately after opening it. Try waiting two seconds after the open and see if it helps.
-br