简体   繁体   English

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

[英]Php code does not execute after return:false;

The Php code below (last on page) checks if the user has pressed the "Reply" button, and then does stuff. 下面的PHP代码(最后一页)检查用户是否按下了“答复”按钮,然后执行操作。 All OK, but if in the huge script that continues below at some point I trigger a javascript alert from Php, which returns false, it does absolutely nothing... How can I make Php remember and execute this part 一切正常,但是如果在某个时候继续在下面继续运行的巨大脚本中,我触发了来自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
    }

even if at some point in the script I have return false; 即使在脚本中的某个时刻我return false; ?

Full snippet of code: 完整的代码段:

/* 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;
}

Having return false; return false; acts as a killer - it exists; 充当杀手-它exists; the script run. 脚本运行。 For example; 例如;

<?php

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

https://eval.in/201188 https://eval.in/201188

The output is just: Hello 输出是: Hello

From reading the docs 通过阅读文档

[...] return also ends the execution of an eval() statement or script file . [...] return还可以结束 eval()语句或脚本文件的执行 If called from the global scope, then execution of the current script file is ended 如果从全局范围调用,则当前脚本文件的执行结束

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM