include-ing results in variable?

From: Date: Sat, 27 Oct 2001 21:53:14 +0000
Subject: include-ing results in variable?
Groups: php.general 
Request: Send a blank email to php-general+get-72593@lists.php.net to get a copy of this message
This is what I'm trying to do, and I think I'm just missing some logic in how to think like PHP. I have a global included file ("global.inc") where I set up variables, open the database, etc, and I include it in the header of every HTML file on the site. One thing I would like to set as a variable is the result of php code in another file ("banner.inc") -- this result is pulled up several times per page, and it seems that it would be more efficient to have it processed once, and then just plug that result into a variable which I can call every time I need that result data. The problem is that it spits out the result as soon as the variable is set! So at the top of every page, it just prints out all the data results immediately rather than waiting for me to echo or print the variable. I have this at the top of the page: <?php $banner = include ("banner.inc"); ?> (which immediately spits out the result of the include!) But I want to print the results several times a page with this: <?=$banner?> I feel certain I'm missing something obvious, but haven't been able to clarify it in my head despite google searching and browsing through a couple of books. thanks for any help! Nathaniel

« previous php.general (#72593) next »