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>

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.

Sign up to request clarification or add additional context in comments.

5 Comments

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.
can I set that to off too? Maybe u can also show the code to totally hide errors.
@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
@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?
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

Your Answer

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.