Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:45:57+00:00 2026-05-25T20:45:57+00:00

Lets say we have 3 files: File1.php, File2.php, File3.php I want to have it

  • 0

Lets say we have 3 files: File1.php, File2.php, File3.php

I want to have it where in File1.php I include() File2.php. Then in File2.php I include() File3.php. I tested it out by writing test text in File3.php, and when I viewed File1.php I could see that test text.

Now my problem is that if I make a variable, say ‘$test = “Success!”;’, in File3.php and then I try to call it in File1.php with ‘echo $test;’ it outputs nothing. It’s not transferring the variables, but it is transferring standard text.

What’s going on here?

(P.S. The reason I’m doing it like this is because of organization.)

EDIT

Here’s my exact code:
(also forgot to mention that I’m grabbing the url of the site first)

file3.php

 <?php
      $test = "Success!";

file2.php

 <?php
      include 'http://' . $_SERVER['SERVER_NAME'] . '/file3.php';

file1.php

 <?php
      include 'http://' . $_SERVER['SERVER_NAME'] . '/file2.php';
      echo $test;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:45:58+00:00Added an answer on May 25, 2026 at 8:45 pm
    echo "$test"; //with double quotes :)
    
    // or echo $test;
    

    Can you provide more code?

    Per http://php.net/manual/en/function.include.php :

    When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward. However, all functions and classes defined in the included file have the global scope.

    Check Example #1

    Edit: Per http://php.net/manual/en/features.remote-files.php :

    In addition, URLs can be used with the include(), include_once(), require() and require_once() statements (since PHP 5.2.0, allow_url_include must be enabled for these)

    So, you cannot include files with the URL, instead, as stated in my comment, use local path. Unless you have allow_url_fopen enabled. This should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say i have 2 files: a.php and b.php a.php $value = test; i
I have 2 mxml files, lets say main.mxml and child.mxml. Now lets say I
Let's say I just want to use PHP include to grab HTML from another
Lets say I have some pdf files stored on my server and I only
Let's say that I have a file (file1.php) with a simple form with the
I want to make a PHP class, lets say Myclass.php. Now inside that class
Using PHP 5.x Question, lets say I want to display results from a database.
I am making an application in php and i have to test certain directories(lets
Lets say I have a plain text file example.txt and I have a PHP
Lets say you have lots of html, css, js, img and etc files within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.