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!
Share:
------ Solution --------------------
$ GLOBALS ['A'] = 'a ';
If (isset ($ GLOBALS ['A'])
Loaded
------ Solution --------------------
Reference:
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.