Avatar of Richard Korts
Richard Korts
Flag for United States of America asked on

php error reporting

I am used to seeing syntax errors in php (if any) when I open a page, especially one I just coded which of course can easily have typos.

I am operating (in this case) on a dedicated cloud server; when there are syntax errors, I just get a blank page. Makes debugging terribly difficult.

The server has "Plesk"; I found a way to a adjust php settings; specifically I set error_reporting to E_ALL | E_STRICT & I set display errors to "on" (see attached).

I still get a blank page.

How can I fix this?

Thanks
PHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Richard Korts

ASKER
I don't know how to reboot the web server, that is probably the issue.

Can I do that from "Plesk"?
gr8gonzo

Here's the general instructions for it:
http://kb.parallels.com/en/122

I'd also recommend enabling graceful restarts to minimize disruptions from restarts:
http://kb.parallels.com/en/112020
Ray Paseur

You may also want to have an error_log file.  You can use something like this in php.ini:

log_errors = On
log_errors_max_len = 1024
error_log = error_log

Open in new window

You can monitor the directories of the site for the appearance of the error_log with something like this:

<?php // find_error_log.php
error_reporting(E_ALL);
ob_start();

// PUT THIS SCRIPT IN THE WEB ROOT DIRECTORY
$path = realpath(getcwd());
$plen = strlen($path);

// THE ERROR LOG FILE NAME
$signal = strrev('error_log');


// IF THERE IS A POST-METHOD REQUEST TO DELETE THE ERROR LOG
if (!empty($_POST['log']))
{
    // MAKE SURE WE ONLY UNLINK THE ERROR LOG FILE
    $test = strrev($_POST['log']);
    if (strpos($test, $signal) === 0)
    {
        unlink($path . $_POST['log']);
        echo '<h3>' . $_POST['log'] . ' Discarded</h3>';
    }
}


// SEE http://php.net/manual/en/class.recursivedirectoryiterator.php#85805
$objs = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
foreach($objs as $name => $obj)
{
    // PROCESS THE ERROR LOG ONLY
    $test = strrev($name);
    if (strpos($test, $signal) === 0)
    {
        $name = substr($name, $plen);
        $form = <<<EOD
<form method="post" style="margin:0; padding:0; display:inline;!important">
<b>$name</b>
<input type="submit" value="Discard?" />
<input type="hidden" name="log" value="$name" />
</form>
EOD;
        echo $form;

        // SHOW THE CONTENTS OF THE ERROR LOG
        echo '<pre>';
        print_r(file_get_contents($path . $name));
        echo "</pre>";
    }
}

$out = ob_get_contents();
if (empty($out)) echo '<h3>Good News! No error_log found.</h3>';

Open in new window

HTH, ~Ray
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes