Get user input on the command line (Windows only)

Get user input on the command line (Windows only)

There is a code to get user input on ‘*nix’, now there is a code to do the same on Windows based system. Put this code in a file, for example input.php and run it with ‘php -f input.php’

<?php

function read() {
$fp=fopen(”con”, “rb”);
$input=fgets($fp, 255);
fclose($fp);
return str_replace(”rn”, “”, $input);

}

echo(”Whats your name? “);
$name = read();
echo(”Hello $name!n”);

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.