jorel jorel - 3 months ago 7
PHP Question

PHP seems to execute script twice

My web server is acting wierd. It seems like it executes scripts (PHP) twice before sending then to apache.

I've run this file:

echo '<pre>';
echo '<br>';

And I know that ++ will give a notice at first, but it's just to investigate if it runs twice. Anyway, the printed session shows that the index-index increases by two each time you load the page.

The webserver is apache2, php5 installed on a debian unit.

Anyone has any ideas?

echo '<pre>'; //Headers and cookies already sent.
session_start(); //Cannot set cookie anymore, system tries again, I guess

Start session first, then output anything. Try placing session_start(); on top