I would to know if its possible to call a PHP function from a external file using XMLHttpRequest (AJAX) like in this form next.
index.php
<script>
            var xhr = new XMLHttpRequest();
            xhr.open('POST','functions.php',true);
            
            xhr.onload = function(){
            //Here it is where I would like to call the function 
            console.log(this.responseText);
            }
            xhr.send(params);  
        }
</script>
functions.php
<?php
    function hello(){
      echo "Hello from function php";
    }
?>
In my project the code I am using is more complex but the example above is simpler and it is the way I would like to call my functions using PHP and AJAX, I was thinking adding <?php hello(); ?> inside xhr.onload function but It didn't work, is there any better idea of how to do this ? I will apprecciete any help..
 
     
    