The function in PHP to obtain user input is input(). This function can obtain input from the command line or Web form. It needs to pass a string parameter as the message to be displayed to the user, and returns the user input string.
Input Statements in PHP
The statements used to get input from the user in PHP are input()
function. This is a built-in function that allows you to get user input from the command line or a web form.
How to use the input()
function
To use the input()
function, you just put it in script and pass a string parameter representing the message to be displayed to the user. This function will pause the script and wait for user input.
<code class="php">$name = input("请输入您的姓名:");</code>
Return value
input()
The function returns the string entered by the user. If the user enters nothing or presses Enter, the function returns an empty string.
Tip
echo
statement in the input()
function to display a message. trim()
function to remove leading and trailing spaces in user input. readline()
function. The above is the detailed content of What is the input statement in php. For more information, please follow other related articles on the PHP Chinese website!