Solved

php.ini setting

Posted on 2014-04-18
6
309 Views
Last Modified: 2014-04-28
What is the php.ini setting that allows for visibility of syntax errors when compiling?

I am using GoDaddy & on the SPECIFIC account I have (for a customer), the GoDaddy rep doesn't even know what I'm taking about.

I know, I know, a number of you have told me to get off GoDaddy. I don;t always have that choice.

Thanks
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 40009661
I think this is what you want.  http://us1.php.net/manual/en/function.error-reporting.php
// Report all PHP errors (see changelog)
error_reporting(E_ALL);

Open in new window

GoDaddy reps are not coders, you shouldn't expect them to know or answer these kinds of questions.  They are probably told not to anyway.
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 40009699
Here is what I use:

<?php
ini_set('dosplay_errors', TRUE);
ini_set('log_errors', TRUE);
error_reporting(E_ALL);

Open in new window

But with that said I have still found GoDaddy installations where I could not get the errors displayed and could only get them logged.  The following script can be placed in the WWW root.  It will find and display the error logs.  Not as great as having real-time information, but at least if you get the screen of death you can get a clue from the logs.

<?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

You may have to define the error_log file in php.ini with something like this.

log_errors = On
log_errors_max_len = 1024
error_log = error_log
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40009729
Note that on Godaddy Linux hosting, you can put a partial 'php.ini' file in the web root but that does not work on their Windows hosting.  On the Windows hosting, it kills the server 'php.ini' file.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Richard Korts
ID: 40009782
There isn't any way to put parameters into php.ini so that EVERY php program reports syntax errors rather than a blank screen?

This seems to be the default at all the other hosts I use and even most of my other GoDaddy accounts.

Thanks
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40009849
On most of the accounts I use, there is no access to 'php.ini' so I have to use the inline versions that Ray and I have shown you.  If you were the hosting company, I think you would find that many, maybe even most, people do not want the errors to show.  So the default is going to be to not show anything that isn't a fatal error.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40010357
Most professional web developers will suppress the display of errors, if only to avoid showing something that looks unprofessional when a "Sorry,..." message could be displayed instead.  The error logs will contain the diagnostic information.  And as you can see from your experience with GoDaddy, the error logs are where you have to go for dependable access to the diagnostics.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 look for a specific file type in a local or remote server directory using PHP.

705 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