【发布时间】:2015-02-23 22:19:45
【问题描述】:
我是 php 新手,我想知道如何创建一个在按钮背景中运行 php 的按钮?对不起,如果我说的不是很清楚。
另外,在社交网站中,如果该按钮会用新信息/文本刷新网页,我如何加载新信息以及删除旧信息?
【问题讨论】:
-
请在代码中表现出一些努力
标签: javascript php html button social-networking
我是 php 新手,我想知道如何创建一个在按钮背景中运行 php 的按钮?对不起,如果我说的不是很清楚。
另外,在社交网站中,如果该按钮会用新信息/文本刷新网页,我如何加载新信息以及删除旧信息?
【问题讨论】:
标签: javascript php html button social-networking
1) 只需使用 POST 方法创建一个 HTML 表单并操作页面本身。当使用按钮发送数据时,PHP 可以分析 POST 请求并为所欲为。
2) 您可能指的是 Web 2.0 。像 Facebook 这样的网站使用 JavaScript 对其后端进行异步 Ajax 调用,然后用新的信息替换屏幕上的信息,而无需重新加载页面。
【讨论】:
我不确定这是否特定于 php。但这里有一个 php 函数中的按钮,它执行某些操作以便获取其他信息。
<?php
function button(){
if(isset($_GET['button'])) {
// this information is shown when the get variable 'button' is set. The var $_GET['button'] is shown too in the case.
echo "The button is clicked, it contains the following GET value: {$_GET['button']}";
} else {
// this information is only shown when there is no variable set in the URL, like 'button=clicked'
echo "The button is not clicked yet.";
}
echo "<a href='?button=click'>Click on the button</a>";
}
// here the function is called.
button();
?>
【讨论】: