运行 Apache 时在哪里查看回显字符串
Where to view echoed string when running Apache
我 运行 Apache 在 MAC 上
$ apachectl 启动
index.html 在 /Library/WebServer/Documents
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>blah</title>
</head>
<body>
<p>test html file: hello world</p>
<button type="button" name="button" action="contact.php">Press me</button>
</body>
</html>
该页面显示在浏览器的 80 端口。
它应该在按下按钮时调用一个 contact.php 文件,这个简单的回显一个字符串。但是我应该在哪里能够看到这个字符串,从而能够检查是否正在调用 contact.php 以及是否按预期调用了 运行?
contact.php
<?php
echo "blah1234567890";
?>
谢谢,
您可以使用:
<form action="contact.php">
<input type="submit" value="Press me">
</form>
而不是:
<button type="button" name="button" action="contact.php">Press me</button>
在您的 index.html
文件中。
使用 formaction
属性,您可以为一个表单指定多个提交 URL。因为表单元素不再需要 action 属性,所以您可以在提交按钮的 formaction
中定义提交 URL(s)。当提交 form
时,浏览器首先检查 formaction
属性;如果不存在,它将继续在表单元素上查找 action 属性。
action
不是 html5 中 button
元素的有效属性。
这是一个选项,可以使用 onclick
属性使按钮像 link 一样工作(如果这是您想要实现的):
<button type="button" name="button" onclick="window.location.href='contact.php';">Press me</button>
我 运行 Apache 在 MAC 上
$ apachectl 启动
index.html 在 /Library/WebServer/Documents
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>blah</title>
</head>
<body>
<p>test html file: hello world</p>
<button type="button" name="button" action="contact.php">Press me</button>
</body>
</html>
该页面显示在浏览器的 80 端口。
它应该在按下按钮时调用一个 contact.php 文件,这个简单的回显一个字符串。但是我应该在哪里能够看到这个字符串,从而能够检查是否正在调用 contact.php 以及是否按预期调用了 运行?
contact.php
<?php
echo "blah1234567890";
?>
谢谢,
您可以使用:
<form action="contact.php">
<input type="submit" value="Press me">
</form>
而不是:
<button type="button" name="button" action="contact.php">Press me</button>
在您的 index.html
文件中。
使用 formaction
属性,您可以为一个表单指定多个提交 URL。因为表单元素不再需要 action 属性,所以您可以在提交按钮的 formaction
中定义提交 URL(s)。当提交 form
时,浏览器首先检查 formaction
属性;如果不存在,它将继续在表单元素上查找 action 属性。
action
不是 html5 中 button
元素的有效属性。
这是一个选项,可以使用 onclick
属性使按钮像 link 一样工作(如果这是您想要实现的):
<button type="button" name="button" onclick="window.location.href='contact.php';">Press me</button>