How to use PHP variable php_self to implement page jump _ PHP Tutorial

Source: Internet
Author: User
Use the PHP variable php_self to redirect pages. We may jump to pages that are similar to html bookmarks, but php programs provide different Web content in the same program by modifying the URL parameters. Try to compare

The page jump here is similar to the jump of html bookmarks, but the php program provides different Web content in the same program by modifying the URL's tail parameters. Try to compare the following two URLs:

Http://www.gxblk.com/pc/index.php

Http://www.gxblk.com/pc/index.php? Page = 2

The difference between the two URLs is that the second URL has one more parameter (? Page = 2), when we open them, the content in the browser is different, and when we click them, they jump in the same page. This is implemented using the PHP variable php_self. The php program compiled by the user will be based on the index. different php tail parameters generate different content, but all use the same web page program (index. php), so we call it "page jump". In fact, it generates another Web document.

We know from the second URL above that the built-in variable $ php_self uses the question mark bootstrap parameter. the specific format is as follows:

$ Php_self? Variable name = value (instance: $ php_sefl? Id = 0)

Variable names after question marks are custom. Generally, they are named as English names with higher readability (which can be abbreviations ). For example, if we let the link point to a functional block of the program to complete a delete operation, we can name it $ del, which is embodied in the code $ php_self? Del = value. if you click this link, the program will perform the delete operation (of course, the delete operation code must be written separately ):

Link code:

 
 
  1. Print
  2. "<A href =" $ php_self? Del = true ">
  3. Delete selected content
  4. </A> ";

Jump Code:

 
 
  1. If ($ del = "true ")
  2. {
  3. // Here is the deletion code
  4. }

The PHP variable php_self can contain multiple parameters. The first parameter usage question (?) Bootstrap. the following parameters are guided with the "and" (&). the format and example are as follows:

[Syntax] $ php_self? Variable 1 = value & Variable 2 = value & Variable 3 = value

[Example] $ php_self? User = blackhorse & id = write & page = 0

In principle, $ php_self's tail parameters should be written together, but variables connected to the number can be separated by spaces or other valid symbols (such as the + sign)-sometimes we do need to separate them, for example, if you want to pass the arv verification, the symbol & will have some impact. the html code generated after the separation is recognized by arv.

The PHP variable php_self is a very useful built-in variable of php. it is usually used for paging and pre-defined operations. The variable in the tail parameter included in it is read using $ in php, as shown in the following address:

Http://www.gxblk.com/pc/index.php? Page = 3

We will read the page number from the above address and display the page content:

$ Conts = echo_conts ($ page );

Echo_conts is a self-compiled function that is used to display the content of each page. The value of the variable $ page is the key and determines the content range extracted by the program from the library file.


In other, the page jumps to different pages, such as html Bookmarks. Instead, the php program provides different Web content in the same program by modifying the URL's tail parameters. Try to compare...

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.