gib
0
Q:

call php function in js

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

New to Communities?

Join the community