Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

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
0
Richard Korts
Asked:
Richard Korts
  • 2
1 Solution
 
gr8gonzoConsultantCommented:
Create and run a script containing:
<?php
phpinfo();
?>

That should tell you where your php.ini file is located so you can make the proper changes. You seem to have the right settings, so if you've rebooted the web server (necessary for PHP.ini changes) and you're still not seeing the errors, then it probably means you're updating the wrong php.ini file.
0
 
Richard KortsAuthor Commented:
I don't know how to reboot the web server, that is probably the issue.

Can I do that from "Plesk"?
0
 
gr8gonzoConsultantCommented:
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
0
 
Ray PaseurCommented:
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now