如何在 PHP 中读取控制台/用户输入? [英] How to read console/user input in PHP?
本文介绍了如何在 PHP 中读取控制台/用户输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 gets
在 Ruby 中获取用户输入.
I use gets
to get an user input in Ruby.
# in 0015.rb
input_num = gets.to_i
p "Your input number is #{input_num}."
我在终端中使用它.
➜ rubytest: ruby 0015.rb
24
"Your input number is 24."
我可以使用终端在 PHP 中执行此操作吗?
Can I do like this in PHP with terminal?
推荐答案
我想你正在寻找 readline 功能
I think you are looking for the readline function
$number = readline("Enter a number: ");
echo 'You picked the number: '.$number;
http://www.php.net/manual/en/function.readline.php
这篇关于如何在 PHP 中读取控制台/用户输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文