Jump to content

How do I include a variable in each PHP page


underthefake

Recommended Posts

I want to include a variable (for example an object $user) in each PHP page.

 

Previously I declared $var in an include file then included that file in every page, however it generates an error in Zend Studio and it's also not very good programming style.

 

I want to know how I can do it any other way.  I was thinking of using constants but I don't know if constants should be used for this purpose and also I do not think constants can be defined as objects.

 

Thank you very much for your help.

using sessions and session variables you can 'carry' variable(s) to multiple pages

http://www.tizag.com/phpT/phpsessions.php

 

I have read online that large objects in the session will impact performance greatly.  My objects will be quite large so I don't think using sessions will be the best.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.