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