编写php页面的body部分实现从1.php跳转到2.php
时间: 2023-08-15 08:03:07 浏览: 43
您可以在1.php页面的body部分添加以下代码以实现跳转:
```html
<body>
<?php
header("Location: 2.php");
exit;
?>
</body>
```
此代码会将请求重定向到2.php页面。请注意,此代码必须在页面的头部之前执行,否则可能会导致错误。
相关问题
编写php页面实现点击写着“跳转”的按钮能从1.php跳转到2.php
您可以在1.php页面中添加以下代码,来创建一个指向2.php页面的超链接,当用户点击“跳转”按钮时,页面将自动引导到2.php页面。
```php
<!DOCTYPE html>
<html>
<head>
<title>跳转页面</title>
</head>
<body>
<a href="2.php">跳转</a>
</body>
</html>
```
这样就可以实现从1.php跳转到2.php。
编写php页面实现点击写着“跳转到2”的按钮能从1.php跳转到2.php,点击写着“跳转到3”的按钮能实现从1.php跳转到3.php
可以使用超链接的方式实现页面跳转,具体代码如下:
```html
<!--1.php-->
<!DOCTYPE html>
<html>
<head>
<title>页面跳转</title>
</head>
<body>
<button onclick="location.href='2.php'">跳转到2</button>
<button onclick="location.href='3.php'">跳转到3</button>
</body>
</html>
```
在这个例子中,我们使用了`location.href`来指定跳转的页面。当点击“跳转到2”的按钮时,会跳转到2.php页面;当点击“跳转到3”的按钮时,会跳转到3.php页面。