简体   繁体   中英

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. 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

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; ?

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; acts as a killer - it exists; the script run. For example;

<?php

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

https://eval.in/201188

The output is just: Hello

From reading the docs

[...] return also ends the execution of an eval() statement or script file . If called from the global scope, then execution of the current script file is ended

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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