[UPHPU] Sharing included data

Jonathan Duncan jonathan at jkdwebmagic.com
Wed Sep 6 12:14:36 MDT 2006


I have a logistical question about PHP.  I have put some example code here 
to help me explain:

http://jkdwebmagic.com/temp/example.txt


I am trying to separate code from content as much as possible and trying 
to figure out the best way to do it.

If you look at my INDEX.PHP file, you see that I make one include call to 
pull in an initialization file and then I instantiate a new object with 
it.

Once I have that object I can use some functions in the object to do all 
my other including for me on-the-fly.  Like this:

$init->getHeader($config, $init);

However, as you can see, I have found it necessary to pass the object 
variable back into the object in order for the HEADER.INC.PHP file to be 
able to use the object and the data in it.  This makes for a messy 
function call like this:

$init->auth->userStatus


Question 1:  Is there was cleaner way to do this?  In other words, is 
there some way to have a file that is included within an object to be able 
to use the methods and data of that object without messy function calls?

Question 2:  Is what I am trying to do, the wrong way to go about it?


Thanks,
Jonathan


More information about the UPHPU mailing list