2007-7-20 12:14
php店小二
*INUX 命令行下 php 读取用户输入
[code]#!/usr/bin/php
<?php
function read_input()
{
$fp = fopen("/dev/stdin", "r");
$input = trim(fgets($fp, 255));
fclose($fp);
return $input;
}
printf("Please supply your name: ");
$name = read_input();
printf(" Hello, $name. ");
?>
[/code]