How to call a function only once (global variable scope)
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