1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest Last month we upgraded BlackHatWorld.com to a new platform - . If you notice anything that requires attention please start a new thread here.
    Dismiss Notice

php redirect question

Discussion in 'Black Hat SEO' started by switch_2012, Feb 10, 2013.

  1. switch_2012

    switch_2012 Power Member

    Joined:
    Feb 28, 2010
    Messages:
    504
    Likes Received:
    228
    Occupation:
    IM
    Location:
    UK
    Hello guys,

    I have seen sometimes people use 'exit;' after the redirect, sometimes don't, can someone please explain the difference or the right way?




    <?php /* Redirect browser */
    header
    ("Location: http://mysite/");
    exit; ?>


    vs



    <?php
    /* Redirect browser */
    header
    ("Location: http://mysite/");
    ?>


    Many thanks

    Switch
     
    Last edited: Feb 10, 2013
  2. mrankin

    mrankin Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 17, 2008
    Messages:
    1,167
    Likes Received:
    550
    Location:
    Australia
    Home Page:
    exit; just terminates a php script. No need to use it, I don't.
     
    • Thanks Thanks x 1
  3. switch_2012

    switch_2012 Power Member

    Joined:
    Feb 28, 2010
    Messages:
    504
    Likes Received:
    228
    Occupation:
    IM
    Location:
    UK
    thank you for the reply mrankin
     
  4. innozemec

    innozemec Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 19, 2011
    Messages:
    5,233
    Likes Received:
    1,793
    Location:
    www.Indexification.com
    Home Page:
    i am used to always use exit;

    there are certain cases and conditions if there's no exit the script either hangs or loops
     
    • Thanks Thanks x 1
  5. wawidr

    wawidr Newbie

    Joined:
    May 10, 2010
    Messages:
    33
    Likes Received:
    11
    Home Page:
    i always use it everytime i am using php redirects as it stops executing codes below it. you can also benefit from using it because it cuts-off loading time since everything else below the exit() is ignored.
     
    • Thanks Thanks x 1