以下是一个简单的PHP实例,展示如何使用PHP实现页面跳转。
| 步骤 | PHP代码 | 说明 |
|---|---|---|
| 1 | PHP代码开始 | |
| 2 | header('Location:http://www.example.com'); | 使用header函数设置Location响应头,实现页面跳转 |
| 3 | exit(); | 使用exit函数结束脚本执行,防止执行后面的代码 |
| 4 | ?> | PHP代码结束 |
将上述代码保存为.php文件,例如index.php,然后访问该文件即可看到页面跳转效果。

示例代码:
```php
header('Location: http://www.example.com');
exit();
>
```
当访问index.php时,浏览器会自动跳转到http://www.example.com。







