Jump to content

Upgraded to 5.3; setting the value of a variable with include file


mrherman

Recommended Posts

Upgraded to 5.3, so I'm trying to make sure that all vars are set.  To do this, I have an "include" file that sets the value of a bunch of vars to 0 (zero).

 

Then I have another include file that echos the values of the, so far, unchanged variables.  I would expect the output to be that each var would be equal to 0.

 

But, no.  I get a ton of error messages that the vars are undefined.  So, does include file "B" know what include file "A" did?

 

Thanks.

Well, since you seem to suggest that it should be working, I wrote a simple script:

 

MAIN.PHP

<?php
include "include_1.php" ;
include "include_2.php" ;
?>

 

INCLUDE_1.PHP

<?php
echo "you are at include_1.php" . "<br />;
$mycolor = "blue" ;
?>

 

INCLUDE_2.PHP

<?php
echo "you are at include_2.php" . "<br />"  ;
echo "mycolor = " . $mycolor ;
?>

 

...and the output is:

you are at include_1.php

you are at include_2.php

mycolor = blue

 

So, it does work and the issue is my crappy code.  Well, let me look further before I give completely up.

 

Thanks!

 

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.