Skip to main content
4 of 4
replaced http://stackoverflow.com/ with https://stackoverflow.com/
function my_big_function() {

    static $result;

    // Function has already run
    if ( $result !== null )
        return $result;

    // Lot of work here to determine $result
    $result = 'whatever';

    return $result;
}

Also see: https://stackoverflow.com/questions/6188994/static-keyword-inside-function

Geert
  • 6.3k
  • 29
  • 42