Hi, I´ve a question about input in php.
Is HTML forms the only way to catch input from a users keyboard or is there other/better ways?
In case there are other phpfunctions just post the names of them and I can look them up. Im looking for functions similar to cin or scanf in C/C++.
thanks in advance
input in php
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
php://stdin
PHP has stdin and stdout streams that you can use.
Code: Select all
<?
$in = fopen("php://stdin", "r");
echo "What is your age: ";
//-------------| 255 is the length of the input string. users can also hit enter.
$input = fgets ($in, $255);
$age = ($input + 10)
echo "in 10 years you'll be $age";
?>