Run PHP Function once

后端 未结 3 1163
天涯浪人
天涯浪人 2021-01-23 02:12

Is there a way to run a PHP FUNCTION \"fun();\" only once when a logged in user accesses a page multiple times?

here is the function.



        
3条回答
  •  花落未央
    2021-01-23 02:53

    Can you not run the function, then store a $_SESSION variable? For example:

    if (!isset($_SESSION['function_ran']) || $_SESSION['function_ran'] != '1') {
        fun(); // run function
        $_SESSION['function_ran'] = '1';
    }
    

提交回复
热议问题