By stashing data in a global variable, we can speed both initial computations (since fib() is recursive) as well as future invocations in the same process.

Neive Fib()
<?php
function Fib($n) {
  if (
$n == || $n == 1) {
    return 
1;
  } else {
    return 
Fib($n 2) + Fib($n 1);
  }
}
?>
Fib() with Caching
<?php
$FV 
= array(=> 1
            
=> 1);

function 
Fib($n) {
  global 
$FV;
  if (!
is_int($n) || $n 0) {
    return 
0;
  }
  
  if(!isset(
$FV[$n])) {
    
$FV[$n] = Fib($n 2) + Fib($n 1);
  }
  
  return 
$FV[$n];
}
?>
PHP5 Fib()
<?php
class Fibonacci {
  static $values = array(0 => 1, 
                         1 => 1);
  static function num($n) {
    if (!is_int($n) || $n < 0) {
	  return 0;
    }
	
    if (!isset(self::$values[$n])) {
      self::$values[$n] = self::num($n -2) + 
	                      self::num($n - 1);
    }

    return self::$values[$n];
  }
}
?>