970_90

Tuesday, 10 February 2015

How to Call a javaScript function in PHP



You can't call a javascript function in PHP directly.

But You can Call a Javascript function from outputted HTML by PHP. It means you can call the javaScript function on conditional. See Example Below:
 
$count= empty($_GET['count'])?0:$_GET['count'];
if(empty($count)){
    echo '<script>callFunc1()</script>';
}elseif($count&lt;=10){
echo '<script>callFunc2()</script>';
}else{
echo '<script>callFunc3()</script>';
}

In this way, we call the JavasScript function in PHP.



No comments:

Post a Comment