PHP 7 Script not display errors, or writing them to the log

I’ve been bashing my head trying to port some super old PHP script to PHP 7.0, which is proving impossible because I can’t figure out what the errors are! If I implement some sort of syntax or parse error, the script happily shows those to me, but I cant get any errors that tell me my function is undefined when I try to call lkasjdfalkjshdfasdF(); (which obviously isn’t set).

Things I’ve tried:

This is my .htaccess file in the same directory as my script

php_flag display_startup_errors on
php_flag display_errors         on
php_flag html_errors            on
php_flag log_errors             on
php_value error_log             "/var/log/apache2/error.log"

I also have this at the top of my script

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

If I add echho 'test'; on one of my lines, it shows the following on the page, and in the error log

Parse error: syntax error, unexpected ''test'' (T_CONSTANT_ENCAPSED_STRING) in /domains/stupidphpscripts.com/public_html/lib/dumbfile.php on line 200

If I add echo asdfasdf(); on one of my lines, I get no output, and there’s nothing in the error log.

I even wrote this silly function

$DebugPointCointer = 0;

function DebugPoint() {
    global $DebugPointCointer;

    echo "Debug point $DebugPointCointer on line " . debug_backtrace(1)[0]['line'] . "n";

    $DebugPointCointer++;
}

So I could make sure that the script was failing where I suspected, but in all honesty, that information didn’t really help me.

What’s left to try?


Source: stackoverflow-php

Leave a Reply

Your email address will not be published. Required fields are marked *