如何在单击PHP按钮时从类中调用函数?

时间:2016-06-29 20:12:56

标签: javascript php function class

朋友。

我有一个像这样的PHP类:

class DiffFunctions {
    function showMessage($msg){
        echo "<script type='text/javascript'>alert('$msg')</script>";
    }
}

我在PHP页面中尝试过这段代码:

<?php
include_once './Classes/DiffFunctions.php';
$myFuns2 = new DiffFunctions();
?>
<button id="sendMsg" type="submit" onclick="$myFuns2->showMessage('You have clicked the button')">Click Here To Show The Message</button>

但它不起作用!

0 个答案:

没有答案