<?php
// ask for input
fwrite(STDOUT, "Enter your name: ");
// get input
$name = trim(fgets(STDIN));
// write input back
fwrite(STDOUT, "Hello, $name!");
?>

源码来自:http://www.jb51.net/article/21879.htm

Related Posts: PHP-命令行获取用户输入值示例 :