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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:06:55+00:00 2026-05-24T17:06:55+00:00

how to include one page into another; for example page 1 include page 2.

  • 0

how to include one page into another;

for example page 1 include page 2. page 2 does not show any content until it get the right arguments.

this is page 2 direct url call

www.mypage.com/execute.php?cmd=test

output is hello world

but when include the same page into page 1 like

include('execute.php?cmd=test');

or

$_GET['cmd']=$test;  
include('execute.php');

sorry but i think you guys didn’t understand me quite right. what im trying to do is, page 2 have some content which must be displayed only when its needed so therefore is have created a function in page 2 so I can call it. the content of must be viewed on page 1 by call. so i have tried to do which normally works ‘execute.php?cmd=test’ but its not this time

  • 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-24T17:06:56+00:00Added an answer on May 24, 2026 at 5:06 pm

    While I think I understand what you’re trying to do, it is the wrong approach. Use a third PHP script that both your pages will include. This way, you won’t have to hack the $_GET super global variable.

    includes/somescript.php

    // do something with $cmd
    if ($cmd == 'test') echo 'Hello world';
    

    page1.php

    $cmd = 'test';
    include 'includes/somescript.php';
    

    page2.php

    $cmd = $_GET['cmd'];
    include 'includes/somescript.php';
    

    Of course, the file includes/somescript.php should not just be executed like that, it should contain a function or a class with arguments that you include, then invoke from your pages. Up to you if you’re going OO or procedural with this.

    Procedural

    includes/somescript.php

    function execute($cmd) {
       // ...
    }
    

    page1.php

    include `includes/somescript.php';
    
    execute('test');
    

    Object Oriented

    includes/somescript.php

    class CommandHandler {
        public function execute($cmd) {
            //...
        }
    }
    

    page2.php

    include `includes/somescript.php';
    
    $h = new CommandHandler();
    $h->execute($_GET['cmd']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to include a JSP page into another JSP page. Let's say
I am trying to get one part of a URL to insert into another.
I have a page, with a navigationbar that loads content, from another page, into
How would I include a page from the public folder in one of my
Is it possible to include one CSS file in another?
One of the problems I often run into, is that I will include '
Hi i am trying to include a webpage link from another website into my
I am starting with Grails and want to have one page with multilanguage content.
I'm trying to reuse a jsf page by including using facelets into another jsf
I can't get server side includes to work. I simply want to include one

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.