爱问知识人 爱问教育 医院库

php如何跳转新窗口

首页

php如何跳转新窗口


        

提交回答
好评回答
  • 2023-04-10 17:30:00

    php跳转新窗口的方法:1、使用【header()】函数将HTTP协议标头输出到浏览器;2、使用meta标签负责提供文档元信息标签,可以实现页面跳转;3、使用javascript使页面自动跳转到新的地址。

    php跳转新窗口的方法:

    第一种方式:header()

    header()函数的主要功能是将HTTP协议标头(header)输出到浏览器。

    语法:

    void header ( string $string [, bool $replace = true [, int $http_response_code ]] )

    可选参数replace指明是替换前一条类似标头还是添加一条相同类型的标头,默认为替换。

    第二个可选参数http_response_code强制将HTTP相应代码设为指定值。 header函数中Location类型的标头是一种特殊的header调用,常用来实现页面跳转。注意:1.location和“:”号间不能有空格,否则不会跳转。

    举例:

    <html><php/* This will give an error. Note the output * above, which is before the header() call */header('Location: http://www.example.com/');exit;>

    注意:

    header执行前不能有任何输出

    location和:之间不能有空格

    header后的php代码还会执行,所以需要注意使用exit;

    第二种方式:meta标签

    Meta标签是HTML中负责提供文档元信息的标签,在PHP程序中使用该标签,也可以实现页面跳转。 若定义http-equiv为refresh,则打开该页面时将根据content规定的值在一定时间内跳转到相应页面。

    < meta http-equiv="refresh"content="1;url=http://www.baidu.com">

    第三种方式:javascript

    通过使用windows.location.href=‘url’; 是页面自动跳转到新的地址

    < ?php $url = "http://www.baidu.com" echo "< script language='javascript'type='text/javascript'>" echo "window.location.href='$url'" echo "< /script>" ?>

    相关学习推荐:php编程(视频)

    y***

    2023-04-10 17:30:00

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):