-1

I have a problem with my lampp. I have activated in php.ini display_errors = 1; and insert function to show me errors in php file.

My script

error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "Hello World!";

header("Content-Type: text/html; charset=windows-1251"); 

My lampp show me no error.

Hosting show me an error,

Warning: Cannot modify header information - headers already sent by 

How can i activated it in my lampp?

Juergen
  • 65
  • 7
  • You should not echo above header. Just change order , it should be okay – Amit Apr 12 '17 at 06:32
  • OP wants to know how to show error not how to fix it. Please see my answer http://stackoverflow.com/questions/43361939/php-how-to-display-warning-warning-session-start-cannot-send-session-cookie/43362060#43362060 – Shahbaz A. Apr 12 '17 at 06:39

4 Answers4

1

Remember headers should be sent before you echo out or print out anything in the PHP script so this:

error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "Hello World!";

header("Content-Type: text/html; charset=windows-1251"); 

SHOULD BE

error_reporting(E_ALL);
ini_set('display_errors', 1);
header("Content-Type: text/html; charset=windows-1251");
echo "Hello World!"; 
Shakti Phartiyal
  • 6,156
  • 3
  • 25
  • 46
0

use

ob_start();

at very starting of your code.

Ravi S. Singh
  • 617
  • 8
  • 15
  • Yes, you are right but in my question I asked. How can i display errors and not eliminate it with ob_start(); or write header before output. I want to see ALL Errors and Warnings in lammp. My lammp show me no warning: Warning: session_start(): Cannot send session cookie - headers already sent by. I want to this error. I dont know how can i activate it. – Juergen Apr 12 '17 at 06:39
0

You must use session_start() before there is any output at all.

Difster
  • 3,264
  • 2
  • 22
  • 32
0

In LAMPP : Try editing php.ini file in /opt/lampp/etc folder.
Find display_errors and error_reporting.
Replace with:
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors=On