Jump to content

Recommended Posts

Hy!

I have 3 files:

 

file 1 (index.php) includes 2 files: file2.php and file3.php

 

File2.php contains $aditionalStuff and in file3.php I want to use $aditionalStuff, but it wont work (like it wasn't initialized).

 

How can I make this work?

 

index.php

include "file2.php";
include "file3.php";

 

file2.php

$aditionalStuff = 'some stuff';

 

file3.php

echo $aditionalStuff;

 

Thanks!

Anyway in file3.php you didnt include file2.php i think.

 

Edit: If you get index.php only its working, but if you get file3.php it has a problem

 

I do not want to include file2 in file3. That's the problem.

And no, my example doesn't work. I have error reporting activated.

Just post your actual code to get the quickest help with why it is not working.

 

There's several million php web sites where what you are doing works.

 

Either your include statements are failing or the few lines of code you posted out of context are either not being executed or they have a different variable scope from where the variable is set.

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.