isset()如果变量已初始化,将返回true。如果您的表单字段的
name值设置为
userName,则提交该表单时,尽管其中可能没有任何数据,但该值将始终为“设置”。
而是
trim()测试字符串并测试其长度
if("" == trim($_POST['userName'])){ $username = 'Anonymous';}
isset()如果变量已初始化,将返回true。如果您的表单字段的
name值设置为
userName,则提交该表单时,尽管其中可能没有任何数据,但该值将始终为“设置”。
而是
trim()测试字符串并测试其长度
if("" == trim($_POST['userName'])){ $username = 'Anonymous';}