1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

unset(variables) even at the end of the execution?

Discussion in 'XenForo Development Discussions' started by Marcus, Aug 2, 2015.

  1. Marcus

    Marcus Well-Known Member

    I unset some variables at the end of a xenforo cron.

    Is it true that the cron is executed separately, and only the one single php file which I execute (like XenForo_CronEntry_MyCron.php) is executed by php? Not other php code is processed?

    If that's the case, the script is actually at it's end and the variables are unset once the script finished it's execution. So it is not useful to unset the variable.
     
  2. katsulynx

    katsulynx Well-Known Member

    It never hurts to unset variables, but it's not really required if you don't want to achieve something specific with it either. There are some special cases where you should clear a huge set of data (an array with 80.000+ entries for example), but I'd never bother to unset a single integer or even an array if not necessary for something else. Variables only exist only within their class/function anyway and are unset after execution.
     
    Marcus likes this.
  3. Xon

    Xon Well-Known Member

    unsetting variables really matters if you are doing a hell of a lot in the one function, otherwise php will garbage collect once the function exits.
     

Share This Page