如何在bootbox确认警报后使用php代码

I want to execute some php code after confirming by user. I mean if the user click yes some php functions should be executed. How can I do it?

bootbox.confirm({
    message: "This is a confirm with custom button text and color! Do you like it?",
    buttons: {
        confirm: {
            label: 'Yes',
            className: 'btn-success'
        },
        cancel: {
            label: 'No',
            className: 'btn-danger'
        }
    },
    callback: function (result) {
        console.log('This was logged in the callback: ' + result);
    }
});

</div>

PHP code is executed server side (before the client sees the page) and the php code is deleted to what is outputed to the user.
To execute some PHP code, you need to make an another request to your server. For that, you could use XMLHTTPRequests or Ajax.

As stated by Ad5001 Gameur codeur autre, you have do a request. Here's an example:

<script type="text/javascript">
function loadXMLDoc() {
    var xmlhttp = new XMLHttpRequest();

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == XMLHttpRequest.DONE ) {
           if (xmlhttp.status == 200) {
               document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
           }
           else if (xmlhttp.status == 400) {
              alert('There was an error 400');
           }
           else {
               alert('something else other than 200 was returned');
           }
        }
    };

    xmlhttp.open("GET", "ajax_info.txt", true);
    xmlhttp.send();
}
</script>

After the user clicks yes, you call the function (in this case, called loadXMLDoc()).

Don't forget to replace ajax_info.txt with your PhP file.