Redirect to specified URL on PHP script completion?

后端 未结 7 1056
逝去的感伤
逝去的感伤 2020-12-13 08:57

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

For example:



        
相关标签:
7条回答
  • 2020-12-13 09:56

    don't forget to put a 'die' after your call to make the redirect happen before the rest of the code on the page is run threw. a. if you have header functions further down the page they will override the ones further up the code.

    b: im assuming you dont want the rest of the code on the page to be run and that why your putting this redirect in in the first place [maybe].

    example:

    <?php
    
    // do something here
    
    header("Location: http://example.com/thankyou.php");
    die();
    
    //code down here now wont get run
    
    ?>
    
    0 讨论(0)
提交回复
热议问题