问题
Why am i asking this ? I'm trying hard to fathom php's superglobal concept ... array data/variables for $_POST are only available to the file to which the form posts back.
They are not available to any of the other files in the Website or Application.
Then why /how is $_POST a superglobal which by it's intutive meaning should mean any variable that is available anywhere / everywhere including all files in a website/ Application where it was not defined.
Can someone please explain me the logic behind this ?
I'm particularly looking to find a direct approach (i.e simply calling/declaring the variable and not indirect approaches like inclding the file containing the variable etc.)to share variables throughout all files in the Website/ Application.
回答1:
Your intuitive definition of superglobal doesn't match how PHP uses the term. The definition of "superglobal" in PHP is that the variable is available in all scopes within the script. The only difference between ordinary global variables and superglobals is that you don't have to use the global
keyword to access them within a function or method.
See the documentation.
来源:https://stackoverflow.com/questions/14018156/is-post-in-php-truly-superglobal