Log in

View Full Version : declaring a variable inside of global.php


derekbeau
09-03-2005, 11:07 PM
I am trying to declare a variable inside of global.php... at the VERY end of the code.

For example, after the large comment box that states the download date and release number, I add the simple declaration (not my real variable, but same concept)


/*================================================= =====================*\
|| ################################################## ##################
|| # Downloaded: 01:10, Fri Aug 12th 2005
|| # CVS: $RCSfile: global.php,v $ - $Revision: 1.321 $
|| ################################################## ##################
\*================================================ ======================*/

$cat = 'dog';
?>


Now, if i try to print that variable immediately after... it is there. However, if I try to print that variable later on, in an included file, it doesnt work.

I am trying to print the variable from the included file in this hook in global_start:


ob_start();
require('library/templates/header.php');
$header_plugin = ob_get_contents();
ob_end_clean();


So what I am trying to do is a <? print $cat; ?> inside of header.php

Any ideas what I am doing wrong and how I can make this work?

Note: I cant just move the variable to the header file. The variable is actually created with a database call and a bit of string manipulation, and I need to keep its code outside of the header.php file.

Andreas
09-03-2005, 11:16 PM
Erm ... global_start is called before the end of global.php, so the Variable simply isn't defined at that point :)

derekbeau
09-03-2005, 11:21 PM
Erm ... global_start is called before the end of global.php, so the Variable simply isn't defined at that point :)

ah! I shouldve known. I even saw the hook when I was looking for a better place to add that variable.

I guess my brain was just thinking that the header file is added after global.php

Anyways, thanks for the help