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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:27:01+00:00 2026-06-12T18:27:01+00:00

I tried to add the command <?php session_start(); ?> before the first line of

  • 0

I tried to add the command <?php session_start(); ?> before the first line of an index.html – file. Aside from that, the file only contains html statements.
When I noticed that the php-code was not getting interpreted, I changed the ending of the file to index.php, which solved that issue.

Now I am wondering whether what I did is an ugly hack or actually an accepted practice? Is it ok to add a php-prefix to a file that is otherwise html?

Also, I am sadly still getting the following error:
session_start() [function.session-start]: Cannot send session cache limiter - headers already sent . In case my above practice is fine, what causes this error?

  • 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-12T18:27:03+00:00Added an answer on June 12, 2026 at 6:27 pm

    What you did is what you’re meant to do.

    Filesystem-based webservers, such as Apache and IIS (for the most part) interpret a requested file based on its file extension and process it accordingly. When a user requests a .html file then the server will return the raw bytes of the file, whereas if the user requested a .php file then it will run it through the PHP module or CGI program which generates the desired output.

    You can configure your webserver (assuming you’re not on a shared hosting service) to always process .html files with PHP, but it’s better to hide implementation details in your URIs and use URL Rewriting instead (something Apache and IIS7+ have full support for).

    With respect to the session_start() error you’re getting – that’s because session_start has to be called before anything is output to the client, which means that the <?php session_start() ?> part has to be at the very start of your document with no plaintext or blank-lines before it. You can have some PHP code before the call, but be sure that the PHP code is not sending any responses or headers.

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

Sidebar

Related Questions

I tried to add a merge strategy to my .gitattributes file in my repository.
I foolishly tried to add a column to a table that I did not
I've tried using mysql dump in the command line and it worked. How do
Simple HTML DOM is basically a php you add to your pages which lets
How do I add an optional flag to my command line args? eg. so
I'm using php function shell_exec with the ls command: shell_exec('ls'); The return is: index.php
I'm trying to call a class (main method) from command line (Windows) with Java.
I tried to create an IPIP tunel using the ip tunnel add command. Now
I have a command that creates a loop: foreach($cart as $line=>$item). When it displays,
I tried to add JRadioButton into JTable by using CellEditor and CellRenderer , but

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.