PHP Jump page Code

Source: Internet
Author: User

  1. Use the header () function

    Enter the following code at the beginning of the PHP page:

    <?php

    Header ("Location:http://www.yedward.net");

    ?>

    Then, we named 1.php, when the access to 1.php, will automatically jump to the Www.yedward.net page, it is important to emphasize that the use of this method, you must write this line of code at the top, if you do not want to write in front, I will provide another method later.

  2. Use meta to achieve jumps

    Enter the following code in the header of the PHP page or the HTML page:

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

    So We name the page 2.php or 3.htm, when access to 2.php or 3.htm, will automatically jump to www.baidu.com this page, note that the content of the number 5 means that after how long to start jumping, here is set 5 means to go through 5 seconds the page will jump to the target page, built Please do not exceed 10 seconds when setting the jump time.

  3. &NBSP;

    use JavaScript to implement the jump

    Enter the following code in the PHP page:

    <?php

    echo "<script language=\" javascript\ ">";

    echo "document.location=\" http://www.baidu.com\ "";

    echo "</script>";

    ?

    Then we name the page 4.php, and when we visit 4.php, we automatically jump to the www.baidu.com page. It is important to note that the JavaScript script itself is not written in this way, because it is used in PHP, so made some changes, you can directly create a. js file, enter the following code, and then refer to the file later:

    <script language= "JavaScript";

    document.location= "http://www.baidu.com";

    </script>

    Let's name it 5.js to make it easier for me to summarize later.

     

  4. Summary of various jump methods for mixing

    Create a new PHP page in which you enter the following code:

    <?php

    $a = 1;

    if ($a ==1)

    Include "1.php";

    if ($a ==2)

    Include "2.php";

    if ($a ==3)

    Include "3.htm";

    if ($a ==4)

    echo "<script language=\" javascript\ ">";

    echo "document.location=\" http://www.baidu.com\ "";

    echo "</script>";

    if ($a ==5)

    Include "5.js";

    ?>

    Save the file, named index.php, Access index.php can jump in the first method, and then constantly modify $a=1 to 2, 3, 4, 5, then you can achieve the above mentioned methods of jumping. In the end, simply mention, in the above mentioned methods, only in the "Use Meta implementation Jump" method mentioned in the jump time setting, then how to set the jump time in other methods, you can use the next sleep () function,

PHP Jump page Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.