返回后PHP代码不执行:false;

时间:2014-10-02 16:06:16

标签: php

下面的Php代码(最后一页)检查用户是否按下了“回复”按钮,然后执行操作。一切都好,但是如果在某个时刻继续下面的巨大脚本中我触发了来自Php的javascript警报,它返回false,它绝对没有...我怎么能让Php记住并执行这部分

if (cmtx_setting('show_reply')) { //if reply field is enabled
        $cmtx_reply_id = trim($_POST['cmtx_reply_id']); //remove any space at beginning and end
        cmtx_is_injected($cmtx_reply_id); //check for injection attempt
        cmtx_validate_reply($cmtx_reply_id, $cmtx_page_id); //validate reply
        $cmtx_reply_to = cmtx_sanitize($cmtx_reply_id, true, true); //sanitize reply
    }

即使在剧本的某个时刻我有return false;

完整代码段

/* Reply To */
    if (!isset($_POST['cmtx_reply_id'])) { //if reply ID not submitted
        $_POST['cmtx_reply_id'] = 0; //set it with a zero value
    }
    if (cmtx_setting('show_reply')) { //if reply field is enabled
        $cmtx_reply_id = trim($_POST['cmtx_reply_id']); //remove any space at beginning and end
        cmtx_is_injected($cmtx_reply_id); //check for injection attempt
        cmtx_validate_reply($cmtx_reply_id, $cmtx_page_id); //validate reply
        $cmtx_reply_to = cmtx_sanitize($cmtx_reply_id, true, true); //sanitize reply
    } else {
        $cmtx_reply_to = 0;
}

1 个答案:

答案 0 :(得分:0)

return false;充当杀手 - 脚本运行exists;。例如;

<?php

echo "Hello";
return false;
echo "World";

https://eval.in/201188

输出只是:Hello

阅读the docs

  

[...] return也会结束执行 eval()语句或脚本文件。如果从全局范围调用,则执行当前脚本文件