php serial communication in linux

Opening the serial port resets that Arduino, unless you have modified the Arduino to not reset when the serial port is opened. Have you?

As it is now, you open some serial port. Without opening a bunch of files, I can't see which one. Nor do I have any clue if that is the right one. As soon as the port is opened, while the Arduino is resetting, you send two characters and close the serial port, resetting the Arduino again.

No matter which language you use to open the serial port, the Arduino will reset. No matter what language you use to close the serial port, the Arduino will reset. Unless you modify it not to.

The key, then, is to open the port, wait while the Arduino resets, and then send it data. When you are done with the Arduino, close the serial port.