Jump to content

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


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!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.