How to interpret PHP page loading for the first time-php Tutorial

Source: Internet
Author: User
How to interpret how PHP is loaded for the first time on a php page like & nbsp; if (! Ispostback) & nbsp; {& nbsp ;..... & nbsp;} to determine whether the page is loaded for the first time! How to interpret the first loading of a PHP page
How php is like in. Net

If (! Ispostback)

To determine whether the page is loaded for the first time!


------ Solution --------------------
$ GLOBALS ['A'] = 'a ';
If (isset ($ GLOBALS ['A'])
------ Solution --------------------
How many times can I load it? Isn't each load a new start? it is similar:

Define ('page1 _ php_loaded', true );
If (defined ('page1 _ PHP_LOADED ') echo' this page is not first loaded ';

Will this happen?

Actually, my code is reversed.
If (defined ('page1 _ PHP_LOADED ') echo' this page is not first loaded ';
Define ('page1 _ php_loaded', true );

This is correct.

As for whether it will be reflected, you should put it in a. php, and then you will know how many times it will be called in B. php.

------ Solution --------------------
First, you need to understand what ispostback is?
Whether the callback is post-based or not.
Literally, $ _ SERVER ['request _ method'] = "POST"

But it is far from that simple because. net can package client code. This allows programmers to use the server language to manipulate client components (the internal mechanism is not described)
As a result,. net adds some control and recognition code to the client code to complete the interaction between the client and the server without the intervention of the programmer.
In this case, ispostback is used to identify the nature of the request from the client, because the first request may require initialization and will not be needed later.

------ Solution --------------------
Make it clear that the web is a stateless request, that is to say, each request is a new request for the server. it can be determined only when a value is set in the session or cookie, however, it is important to consider whether the cookie is disabled on the client. All define statements are invalid .. The same is true in net. an ispostback may be a variable that has obtained a value from the cookie or session.

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: 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.