how to call a php function from javascript code example
Example 1: call javascript function from php
// The most basic method
<?php
echo '<script type="text/javascript">',
'someJsFunc();',
'</script>';
?>
// However, if what you are trying to achieve requires more complexity,
// You might be better off adding the V8JS module, see link below
Example 2: call php function in js
<script>
var phpadd= <?php echo add(1,2);?>
var phpmult= <?php echo mult(1,2);?>
var phpdivide= <?php echo divide(1,2);?>
</script>
Example 3: how to call js function from php
<?php
if(your condition){
echo "<script> window.onload = function() {
yourJavascriptFunction(param1, param2);
}; </script>";
?>