In website program development, there are many webpage data submission pages. The simplest is the login page, which cannot be blank when the input content is submitted in the text box on the login page. In addition to controlling the text box through JavaScript scripts on the client side, we can also make judgments on the server side. In website program development, there are many webpage data submission pages. The simplest is the login page, which cannot be blank when the input content is submitted in the text box on the login page. In addition to controlling the text box through JavaScript scripts on the client side, we can also make judgments on the server side.
Generally, form verification is performed once at the front end and once at the backend.
You can useEmpty () functionTo complete,
The empty () function checks whether the variable is null. if the variable is null or zero, true is returned. When the variables are: "", 0, "0", null, false, array (), var $ var, and objects without any attributes are considered null. The empty () function syntax is as follows:
bool empty ( mixed $var )
The var parameter is the input variable.
Application example
Use the empty () function to verify whether the username on the logon page is empty. the code is as follows,
The logon page code is as follows:
First PHP community (php1.cn)
The code execution result is as follows:
Code for verification on the server side using the empty () function:
Return ";} else {echo". The username is $ user. the password is $ password ";}?>
If the username and password text box is blank, click log on now to verify the submitted form information. the running result is as follows:
The above is a simple instance with the empty () function check being empty. I hope you will have some knowledge.
The preceding figure shows how to use the empty () function to determine whether the input in the form text box is empty? For more information, see other related articles in the first PHP community!