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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:49:43+00:00 2026-05-17T22:49:43+00:00

I have the Index file like this <?php include(‘file1.php’); include(‘file2.php’); ?> in file1.php I

  • 0

I have the Index file like this

<?php
include('file1.php');
include('file2.php');
?>

in file1.php I am having the code like below.

<?php
echo "hai";
?>

I am trying to redirect the page by using header('Location:index.php').It throws an error something like the output already started.I know for header if we give the echo statement it throws an error.In this situation I am trying to redirect by using Javascript window.location.href='index.php' .It gives me the expected output and there is no error.Why?.

  • 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-17T22:49:44+00:00Added an answer on May 17, 2026 at 10:49 pm

    The PHP header command is sending an instruction to the response stream that the browser will interpret as a redirect to a new location. But, by its nature, you can only send a header of any kind before you has started sending content. In your example, you send the content “hai” then tried to send the header.

    Now your javascript is executed in the broswer by the javascript engine. As such, the window.location is telling the javascript engine to make the browser request a new page. This is independent of any information contained within the http stream (in theory, the location could be something other than http such as ftp or a mailto).

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

Sidebar

Related Questions

I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
So I have a menu in a php file that looks like this (This
If I have an index.php file that includes inc/footer.php I would write: include 'inc/footer.php';
So I have this index.php page: <?php include main.php; ?> <html> <head> <link rel=stylesheet
I have an index.php file which has to process many different file types. How
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
The setup: I have a standard .php file (index.php) that contains two includes, one
Is there a way to achieve the following? In my /www/var/public_html/index.php file i have
I have html file with php code in it. It contains code to connect
For example, if I have a page located in Views/Home/Index.aspx and a JavaScript file

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.