is $_POST in php truly superglobal? [closed]

感情迁移 提交于 2019-12-25 00:21:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!