[Resolved] Run a function only once – share variable across templates PHP
I have a function (say call_api()) which reaches out to API and stores value in a variable which I then want to share across templates. I have tried a number of ways :
1) Using Session Variable and sharing the variable, but the function is called more than once.
2) Using static variable to run function only once.
Now, I want the function to run once when user loads the website, and store the value in a function which is stored in a variable which can be shared across various templates.
I have done extensive Google Search but was unable to come up with a solution. Can anyone please point me to the right direction ?
- The topic ‘[Resolved] Run a function only once – share variable across templates PHP’ is closed to new replies.