如何通过单击按钮调用PHP函数
我创建了一个名为functioncalling.php的页面,其中包含两个按钮:Submit和Insert。作为PHP的初学者,我想测试单击按钮时执行的功能。我希望输出出现在同一页面上。所以我创建了两个函数,每个按钮一个。functioncalling.php的源代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<body>
<form action="functioncalling.php">
<input type="text" name="txt" />
<input type="submit" name="insert" value="insert" onclick="insert()" />
<input type="submit" name="select" value="select" onclick="select()" />
</form>
<?php function select(){
echo "The select function is called.";
}
function insert(){
echo "The insert function is called.";
}
?>这里的问题是在点击任何按钮后我没有得到任何输出。
我到底哪里错了?
叮当猫咪
12345678_0001
慕丝7291255
临摹微笑
随时随地看视频慕课网APP