在PHP脚本完成时重定向到指定的URL? [英] Redirect to specified URL on PHP script completion?

查看:75
本文介绍了在PHP脚本完成时重定向到指定的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当运行完特定的网站后,如何才能获得一个PHP函数?

How can I get a PHP function go to a specific website when it is done running?

例如:

<?php
  //SOMETHING DONE
  GOTO(http://example.com/thankyou.php);
?>

我真的很想要以下内容...

I would really like the following...

<?php
  //SOMETHING DONE
  GOTO($url);
?>

我想做这样的事情:

<?php
  //SOMETHING DONE THAT SETS $url
  header('Location: $url');  
?>

推荐答案

<?
ob_start(); // ensures anything dumped out will be caught

// do stuff here
$url = 'http://example.com/thankyou.php'; // this can be set based on whatever

// clear out the output buffer
while (ob_get_status()) 
{
    ob_end_clean();
}

// no redirect
header( "Location: $url" );
?>

这篇关于在PHP脚本完成时重定向到指定的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆