Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
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: http://stackoverflow.com/questions/6188994/static-keyword-inside-functionhttps://stackoverflow.com/questions/6188994/static-keyword-inside-function

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: http://stackoverflow.com/questions/6188994/static-keyword-inside-function

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

Coding style
Source Link
Geert
  • 6.3k
  • 29
  • 42
function my_big_function()
  { 

    static $result;

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

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

    return $result;
}

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

function my_big_function()
 {
    static $result;

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

    // Lot of work to determine $result
 
    $result = TRUE;
    return $result;
}

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

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: http://stackoverflow.com/questions/6188994/static-keyword-inside-function

added 87 characters in body
Source Link
Geert
  • 6.3k
  • 29
  • 42
function my_big_function()
{
    static $result;

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

    // Lot of work to determine $result

    $result = TRUE;
    return $result;
}

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

function my_big_function()
{
    static $result;

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

    // Lot of work to determine $result

    $result = TRUE;
    return $result;
}
function my_big_function()
{
    static $result;

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

    // Lot of work to determine $result

    $result = TRUE;
    return $result;
}

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

Source Link
Geert
  • 6.3k
  • 29
  • 42
Loading