Ok, ho capito dov'č il problema: devi usare fgets e non fread:
Codice PHP:
<?php
$lettura=fopen('php://stdin', 'r');
$scrittura=fopen('php://stdout', 'w');
$opzione="";
while (($opzione!="1") && ($opzione!="2")):
fwrite($scrittura, "1) uno\n");
fwrite($scrittura, "2) due\n");
$opzione = fgets($lettura, 20);
$opzione=substr($opzione,0,1);
if ($opzione == "1"):
fwrite($scrittura, "Scelto uno\n");
elseif ($opzione == "2"):
fwrite($scrittura, "Scelto due\n");
else:
fwrite($scrittura, "Sbagliato!\n");
endif;
endwhile;
?>
Ciao!