Solved

php error reporting

Posted on 2014-01-14
4
340 Views
Last Modified: 2014-01-14
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
Comment
Question by:Richard Korts
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 39780010
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
 

Author Comment

by:Richard Korts
ID: 39780045
I don't know how to reboot the web server, that is probably the issue.

Can I do that from "Plesk"?
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 39780090
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
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39780541
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP strings vs array errors 13 32
Dynamic Dropdowns 15 32
Email called spam 5 36
Wordpress Only run code if on a certain page 11 22
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question