2

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>
James Dunn
8,32414 gold badges55 silver badges88 bronze badges
asked Apr 13, 2012 at 5:59

1 Answer 1

8

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.

answered Apr 13, 2012 at 6:00
5
  • 2
    It'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. Commented Apr 13, 2012 at 6:02
  • can I set that to off too? Maybe u can also show the code to totally hide errors. Commented 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 question Commented 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? Commented 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 screen Commented Apr 13, 2012 at 6:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.