嵌套条件要求PHP

时间:2014-02-13 22:43:38

标签: php if-statement conditional-statements strip-tags

必须有一种更有效的方式来编写此代码(如下所示)有人能提供一种能够以更有效的方式显示多个If的解决方案吗?

if (  isset($_POST["submit"])  
   || isset($_POST["submit_x"])
   ) {

    // strip_tags removes tags and then we compare to the original contents
    if (strip_tags($_POST['fld_comments']) !== $_POST['fld_comments']) {

        // Drop post as it had html in it (!==  means Not Identical )
        echo '<h2>No html tags allowed in comments</h2>';
        $blindError = true;  

    } else {

        // run secondary code such to process form

    }
}

1 个答案:

答案 0 :(得分:2)

您的代码绝对优秀且高效。我没有看到任何问题,好吧,你可以使用一点点括号,但没有什么严重的。

我的意思是:

if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
相关问题