Serial communication with PHP

Good job with getting this to work with PHP!

I have one question though, have you tried not closing the file descriptor right after you write to it? Something like

<?PHP

$fp =fopen("com7", "w");
fwrite($fp, chr(a));

sleep(60);

fclose($fp);

?>

this way you would have time to read the input from the Arduino before it closes the port and resets. It would be fun to know if this way works but in your case, it isn't a viable solution because the php script to control the Arduino would be executed via the web.

In cases where PHP isn't used from the web (running from command line instead of over Apache) and your PHP script uses an infinite loop to receive / send data constantly to the Arduino, this solution could be possible I guess.