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

  • SEARCH
  • Home
  • 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 5848749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:54:11+00:00 2026-05-22T12:54:11+00:00

So i have three files. FILE 1 includes FILE 2 which includes FILE 3

  • 0

So i have three files.

FILE 1 includes FILE 2 which includes FILE 3

FILE 1 needs to print VAR 1 which is defined in FILE 3

how would I do that?
Its not echoing out for me

file 1

<?php
if ($_GET["pg"]==false)
echo "<title>Socal Mods</title>";
else
echo $title_name;
?>

file 2

<?php 
if ($_GET["pg"]==false)
include("home.php");
else
include("".$_GET["pg"].".php");
?>

file 3

<?php $title_name="<title>Socal Mods</title>" ?>

file 3 is being parsed into file 1 which is the display container, but the %title_name is not echoing

  • 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-22T12:54:12+00:00Added an answer on May 22, 2026 at 12:54 pm

    One thing first about how you access the GET variables. You check the value using $_GET["pg"] == false. Note that this expression will fail to do what you expect in a lot situations. In fact, the value will never be directly false. The only way it will equal to false if it is empty or unset (in which case you will also get a compiler warning, which you should avoid). Usually a safer way to check if the value was set is using isset( $_GET["pg"] ).

    The next thing I want to address is a security problem you introduce. You use the GET value directly to include a file with that name. If I was a user with malicious intent, I could easily set the pg value to something, you usually wouldn’t expect and which break your website in some way. You generally should avoid using data the user entered somehow (request parameters are user data), and make sure to sanitize them first. A good way to do this, when you plan to use the value as a base to which page you want to include, would be to have some kind of whitelist of acceptable/allowed values. Then you can check if the entered data is in that whitelist and if that is the case, include the correct page. Another simple way would be using a switch statement to simply go through all accepted cases.

    Now finally, onto your problem: I’m not sure if this was just a mistake when you posted the code, but file 1 is missing the include of file 2. As such you will never include file 3, and of course the variable will never be set.

    Another problem might be the usage of the GET value. If the value does not contain the exact filename (as in casing and no extra whitespace), then the file won’t be found. It is a good idea to echo out the filename you want to include in file 2, just to check if you are making any mistakes. The whitelist as explained above would be another way to make sure that you are trying to include the correct file.

    Finally, you should enable error reporting on your server, you can do that either in your server configuration, or by adding the following line to the top of your first file (i.e. file 1):

    error_reporting( E_ALL );
    

    That way you will get errors and warnings that will tell you if something unexpected happened at runtime, and you might see your mistake easier.

    Old answer

    In general it works like this:

    File 1:

     <?php
     include 'file2.php';
     echo $myVariable; // prints 'Hello World!'
     ?>
    

    File 2:

     <?php
     include 'file3.php';
     ?>
    

    File 3:

     <?php
     $myVariable = 'Hello World!';
     ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which during it's run sometimes needs to call python in
As we know in C++ we have class iostream, which is inherited from istream(basic_istream)
I have written down a program in c and I am trying to create
I have a class, say class AddElement{ int a,b,c; } With methods to set/get
I'm trying to serialize a pointer to a polymorphic class Shape . So I
I'm new with python programming and GUI. I search on internet about GUI programming
I'm using jQuery Templates for a bunch of a site I'm working on, and
Good day good-looking computer people, I might be asking a bit too much, but
I am trying to understand the following behavior of shared libraries in C Machine
As in the question Creating simple c++.net wrapper. Step-by-step I am tring to use

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.