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 7758381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:20:44+00:00 2026-06-01T13:20:44+00:00

Possible Duplicate: get name of current PHP script in include file Can an included

  • 0

Possible Duplicate:
get name of current PHP script in include file
Can an included PHP file know where it was included from?

Does that headline make sense? 🙂

Can you determine the PHP page that you put the <?php include 'SomeFile.php'; ?> into, FROM THE INCLUDED PAGE??

In the page to be ‘INCLUDED‘ have an if statement based on the destination that grabs it?

Am I even saying this right?

Thanks All!

THE SOLUTION:

PAGEMAIN1.php

<?php
$MAIN2 ='';
$MAIN1 = 'MAIN1';
include 'PAGE1.php';
include 'PAGE2.php';
include 'PAGE3.php';
include 'PAGE4.php';
?>

PAGEMAIN2.php

<?php
$MAIN1 ='';
$MAIN2 = 'MAIN2';
include 'PAGE1.php';
include 'PAGE2.php';
include 'PAGE3.php';
include 'PAGE4.php';
?>

PAGE1.php

<?php
$PAGE1 = 'PAGE1';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 1 being "INCLUDED" in MAIN 1)<br>';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 1 being "INCLUDED" in MAIN 2)<br>';
    }
?>

PAGE2.php

<?php
$PAGE2 = 'PAGE2';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 2 being "INCLUDED" in MAIN 1)<br>';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 2 being "INCLUDED" in MAIN 2)<br>';
    }
?>

PAGE3.php

<?php
$PAGE3 = 'PAGE3';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 3 being "INCLUDED" in MAIN 1)<br>';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 3 being "INCLUDED" in MAIN 2)<br>';
    }
?>

PAGE4.php

<?php
$PAGE4 = 'PAGE4';
if($MAIN1 == 'MAIN1'){
    echo '(This is PAGE 4 being "INCLUDED" in MAIN 1)<br>';
    }
if($MAIN2 == 'MAIN2'){
    echo '(This is PAGE 4 being "INCLUDED" in MAIN 2)<br>';
    }
?>

OUTPUT FROM PAGEMAIN1.php

(This is PAGE 1 being "INCLUDED" in MAIN 1)
(This is PAGE 2 being "INCLUDED" in MAIN 1)
(This is PAGE 3 being "INCLUDED" in MAIN 1)
(This is PAGE 4 being "INCLUDED" in MAIN 1)

OUTPUT FROM PAGEMAIN2.php

(This is PAGE 1 being "INCLUDED" in MAIN 2)
(This is PAGE 2 being "INCLUDED" in MAIN 2)
(This is PAGE 3 being "INCLUDED" in MAIN 2)
(This is PAGE 4 being "INCLUDED" in MAIN 2)

Just in case you wanted to know. 😉 Thanks!

  • 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-06-01T13:20:45+00:00Added an answer on June 1, 2026 at 1:20 pm

    What you can do is make a global variable that you use in all the pages that includes the subpage. In the subpage you can then check which page you are on. Does that make sense? 😉

    page1:

    <?php
       $THISPAGE = "page1";
       include("subpage.php");
    ?>
    

    page2:

    <?php
       $THISPAGE = "page2";
       include("subpage.php");
    ?>
    

    subpage:

    <?php
       if ($THISPAGE == "page1")
          ...
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: From the string name of a class, can I get a static
Possible Duplicate: jQuery: get the file name selected from <input type=file /> I have
Possible Duplicate: PHP REGEX: Get domain from URL I am working on a project
Possible Duplicate: Dynamically retrieving current method's name Obj-C introspection: How can a method reference
Possible Duplicate: How can I get the name of function inside a JavaScript function?
Possible Duplicate: How do I get the name of a property from a property
Possible Duplicate: How do I get the name of the current executable in C#?
Possible Duplicate: How can I find the method that called the current method? How
Possible Duplicate: iOS: How to get a proper Month name from a number? How
Possible Duplicate: How do I get the current logged in Active Directory username from

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.