当测试张贴的表单值是否包含等于XX php的文本时,正确的语法是什么?


what is the correct syntax to use when testing if a posted form value contains text equal to XX php

我想写一个if语句来测试是否张贴表单值等于xx

 $field = $_POST['myfield'];
 if($field == 'Hello world') {
 / /do something 
 }

这是正确的…?

谢谢

是。但首先检查是否设置

$field =(isset($_POST['myfield']))?$_POST['myfield']:'';
    if($field == 'Hello world') {
     / /do something 
     }