I have this mark up:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
ini_set('display_errors', 1);
ini_set('log_errors', 1);
include_once('../API/session_management.php');
//Checking session fixation:
$sess=new session_management();
$sess->set_session_configurations();
$sess->prevent_session_hijacking();
?>
sdfsd
<a href=""></form>
<form>
<input type="text" name="test"/>
</form>
</body>
The problem is that when I run the code, there is an error. A blank page is being printed. No error is displayed. Why is this, and how can I enable errors?
This is the output that I get after and before changing the Display errors to on in php ini and restarting apache:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
1 Answer 1
The two lines you need are
ini_set('display_errors', 'On');
error_reporting(E_ALL);
It's much better to set these in the php.ini
file for your development environment. This removes non-production code from your project and solves problems like syntax errors causing your ini_set()
and error_reporting()
calls not to be executed (thanks Corbin).
Another suggestion, place your PHP code before any HTML starts (right at the top of the script). It looks like you're dealing with sessions which should be done before anything is added to the output buffer.
-
2It's also worth noting that if his default display_errors is Off, and there's a syntax error, no error will be displayed since the call to ini_set will never happen.Corbin– Corbin04/13/2012 06:02:19Commented Apr 13, 2012 at 6:02
-
can I set that to off too? Maybe u can also show the code to totally hide errors.Jürgen Paul– Jürgen Paul04/13/2012 06:03:23Commented Apr 13, 2012 at 6:03
-
@JackSpairow I'm not sure what you're asking or even how it relates to this question / answer. Perhaps pose your query as a separate questionPhil– Phil04/13/2012 06:10:12Commented Apr 13, 2012 at 6:10
-
@DmitryMakovetskiyd It doesn't solve your question but when I said "top", I really meant top. Put your PHP code before the
<!DOCTYPE html>
line. Anything in your Apache error log or PHP error log if you have one?Phil– Phil04/13/2012 06:14:05Commented Apr 13, 2012 at 6:14 -
I did put it in the top. I have no idea what is apache error or php log.. I want to see it on the screenDmitry Makovetskiyd– Dmitry Makovetskiyd04/13/2012 06:16:22Commented Apr 13, 2012 at 6:16