Undefined variable error in PHP include file

You have to declare the variable to global like this:

function phpRocks() {
global $page;           //set variable to global
require("includes/dostuff.php");
}

mario's got it. Do this:

function phpRocks() {
    global $page;

    require("includes/dostuff.php");
}

add global var in you function like that

function phpRocks() {
  global $page;
  require("includes/dostuff.php");
}

You are including the file inside a function. Therefore the scope of all the included code is the scope of the function. The variable $page does not exist inside the function. Pass it in:

function phpRocks($page) {
    require "includes/dostuff.php";
}

phpRocks($page);