Is it bad practice to write to $_POST?

后端 未结 7 1583
心在旅途
心在旅途 2021-01-11 17:55

If this is file_1.php


7条回答
  •  长发绾君心
    2021-01-11 18:18

    It's absolutely fine to do that. If you look at all the big php frameworks (CI, cake, joomla etc), they all post via the index.php page thro' a controller to the final destination (usually using some helper code). Therefore, the $_POST variable is buried quite a few layers deep. Remember, the $_POST variable is ONLY valid for that transitory moment while the http request is active, so when the request is complete, all variables are reset to null.

    The $_SESSION variable CAN be used if you want to persit between requests - tho it depends on your requirement and scenario.

提交回复
热议问题