php If is not equal to empty judgment method: first obtain the content of the text box through "$_POST['content'];"; then use "if($content==""){}else{} "method to determine whether the text box content is empty; finally execute the relevant file in the browser.
To determine whether the value of a form element is empty in PHP, you first need to submit the form, and then get the form element based on its name to determine whether it is empty.
Examples are as follows:
<?php if($_POST['sub']){ //获取文本框的内容 $content=$_POST['content']; if($content==""){ echo "文本框内容为空!"; }else{ echo "文本框内容不为空!"; } } ?> <html> <head> <title>演示</title> </head> <body> <form name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="input" name="content"/> <input type="submit" name="sub" value="提交"/> </form> </body> </html>
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to use if in php to determine whether the text box is equal to empty. For more information, please follow other related articles on the PHP Chinese website!