Javascript 在html中调用php函数

Javascript 在html中调用php函数,javascript,php,jquery,html,Javascript,Php,Jquery,Html,假设我有一个名为test.php的php类,在该类中有一个名为my_test的函数 现在我想在单击按钮时调用此函数,因此在名为my_page.html的html类中-- <button name="mytestbutton" type="button" onclick="my_test()" class="btn btn-primary btn-xs" value="my_test()">My Test</button> 但是我需要写一些东西,以便它在我的html中识别

假设我有一个名为test.php的php类,在该类中有一个名为my_test的函数

现在我想在单击按钮时调用此函数,因此在名为my_page.html的html类中--

<button name="mytestbutton" type="button" onclick="my_test()" class="btn btn-primary btn-xs" value="my_test()">My Test</button>

但是我需要写一些东西,以便它在我的html中识别onclick应该执行函数my_测试。但是我如何在html按钮中调用我的函数,任何人都能找到解决此问题的方法。

html、Javascript和按钮的活动在客户端和web浏览器中运行。PHP在服务器上运行。向服务器发送信息的唯一方法是向服务器发送一个新的页面请求、表单提交或所谓的AJAX请求,并让PHP代码提取发送给它的数据

此数据通常通过PHP“superglobals”$\u GET、$\u POST、$\u请求等获取

或者,您可以用JavaScript编写my_测试,并在浏览器上运行它

<script>
function my_test() {
   // your button code here
}
</script>

<!-- .. some HTML .... -->

<button name="mytestbutton" type="button" 
 onclick="my_test()" class="btn btn-primary btn-xs" value="my_test()">My Test</button>

您必须在服务器端进行管理。同时使用javascript、ajax和php。@BhavinSolanki您不能调用这样的php函数。有人能给我举个例子说明如何使用ajax或javascript来解决这个问题吗