关闭浏览器时如何执行php指令?

I want to execute instructions in the momant of closing the browser, for example the instruction is a requeste sended to update the database?

PHP has nothing to do with the browser. PHP can't interact with it in any way directly, but you can use JavaScript to communicate with your PHP. Doing something when the browser is closed is not always reliable because the browser could close unexpectedly, but you can attempt to gather the info using an onunload event listener to send an HTTP request to run your PHP script.

window.onunload = function(){
    var xmlhttp = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
    var url = "MyPHPScript.php";
    xmlhttp.open("GET",url,false);
    xmlhttp.send();
}