Hello everybody,

Im writing an application that takes various different classes.

i basically have a bootstrap type of file that requires all the needed classes.
inside each individual class file at the bottom, i have instantiated the class.

later on in other theme files i want to use some methods of the classes
i get an error as so: Notice:

Undefined variable: message in ...

this should not be happening since i have already instantiated the classes in files before the current one.


Im using php v. 5.2 on my server.

im basically included from the root index file, my bootstrap. and below that, my themes folder.

in my themes/default/account/login i cannot use classes 1-3 that have been included and instantiated previously which is absurd as i do not know why i dont have access to them.

File Structure:

  • /theme/
  • /default/
  • /account/
  • /login/
  • index.php



  • class1.php

  • class2.php

  • class3.php


any help would be appreciated, thank you.

If somebody could please try to help me out with this i would be really grateful.

Ok i did some reading on php.net

so this is what i came up with.
it comes down to the variable scope.

if i include "file.php" which inside file.php i define a variable: $test = "it works";

and then if in the file that has the include in it i want to echo out the var "$test"

it will say "it workes"


if i implement the same thing but i have a function that inside i call an include, the included file has the scope of inside the function.

so if i were to try and echo out a variable that was declared inside the function

it would not work.

Yeah i solved my problem. i have a router that is pulling in files. so i just declared all my classes as global in the router function.