For Windows the Example 1 looks same this one:
<?php
exec('mode com1: baud=9600 data=8 stop=1 parity=n xon=on');
// execute 'help mode' in command line of Windows for help
$fd = dio_open('com1:', O_RDWR);
while (1) {
$data = dio_read($fd, 256);
if ($data) {
echo $data;
}
}
?>