<?php
function bar() {
    echo "bar() called\n";
    return 1;
}

function foo() {
    static $i = bar();
    echo $i++, "\n";
}

echo "BEGIN\n";
foo();
foo();
foo();
Output
BEGIN bar() called 1 2 3