Welcome Guest, Not a member yet? Register   Sign In
trying to run function just once
#16

(This post was last modified: 06-23-2021, 03:27 AM by craig.)

Every single page view in a PHP web application is an entirely new instance of the code execution - all the init() and construct() functions will get called. At the end of the script execution (e.g. viewing a page), the classes and variables are destroyed. PHP apps work entirely different to C programs, so that knowledge doesn't transfer exactly.

For your use case, you could move your function call to get_from_locker() to your login handling code, after verifying their password - so you only do it once you have a valid user. Then you don't need to call it again anywhere, and you don't need to do it in any init() or construct() calls.

If you do insist on doing it in those places, then use Sessions to keep track of whether or not you've got the image.
Reply


Messages In This Thread
trying to run function just once - by richb201 - 06-21-2021, 09:06 AM
RE: trying to run function just once - by ikesela - 06-21-2021, 07:10 PM
RE: trying to run function just once - by paliz - 06-22-2021, 04:19 AM
RE: trying to run function just once - by craig - 06-23-2021, 03:26 AM
RE: trying to run function just once - by paliz - 06-24-2021, 02:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB