Why error_reporting in browser KO?

Hi all,

Reading Ray Paseur advices, I'm trying to set error_reporting to ALL for my PHP installation.
I'm using MAMP.

My PHP version is 5.6.2. so I've updated the php.ini located at: /Applications/MAMP/conf/php5.6.2 by uncommenting the line "error_reporting  =  E_ALL"
In addition, I've updated display_errors by setting it to “On”.

I have restarted the server but nothing appears in the browser.
I can see my error in php_error.log.

Regards,
Richard
LVL 1
Richard Coffree-commerce Product ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
In your site PHP pages (usually the header file as it is the common file) add at the top

error_reporting(E_ALL);
ini_set('display_errors', 'On');

Open in new window

0
Ray PaseurCommented:
Search the entire php.ini file to be sure you don't have an override of a setting later in the file.  Not sure, but IIRC the settings below will overwrite the settings above.  If you're using htdocs as your web root directory, you can put the php.ini file in the web root htdocs directory.
0
Richard Coffree-commerce Product ManagerAuthor Commented:
Ray,

I checked the entire php.ini file and there is no override.

Gary,

I tested your solution but it fails.

I will continue my investigation.
It should have something preventing for the display.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

GaryCommented:
Are you sure there is any errors?
0
Ray PaseurCommented:
If there are errors in the log, but no corresponding error display, then the errors occurred but did not get displayed.  Question: Did anything get displayed by the scripts that failed?  If you need a predictable test case, PHP trigger_error() can help.

If it helps, you can use this script to find and display the contents of error_log (or similarly named files - just customize it for your installation).  It goes in the WWW root directory and searches everything in the directory tree.

<?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 THIS 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);

// UNFORTUNATELY THIS DOES NOT WORK AT PHP 5.4
// var_dump($objs);

// ITERATE OVER THE OBJECTS
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>' . PHP_EOL;
    }
}

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

Open in new window

0
Richard Coffree-commerce Product ManagerAuthor Commented:
Hi guys,

Ray, I will test your solution later but to answer to Gary, this is what I got from the log file:

[01-Dec-2014 11:56:28 Europe/Berlin] PHP Parse error:  syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in /Users/richardcoffre/Documents/blackhole/Dropbox/dev-web/php/carriers/test-error-reporting.php on line 11

Open in new window


Should it appear in the browse? I think so, mayb I'm wrong.
0
GaryCommented:
Post the code in test-error-reporting.php
0
Ray PaseurCommented:
Short answer: Yes, a PHP parse error should be visible in the browser.  Are you running scripts out of something like localhost:8888 to access a directory like htdocs for the web root?  If so, you may be able to put php.ini in the htdocs root directory.
0
Richard Coffree-commerce Product ManagerAuthor Commented:
Hi  guys,

Thank you for your help.

I did them all but failure still be there.

This is my code

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "start";
// This is an error I want to see using error reporting
echo "fff 

?>

Open in new window


And I attached some screenshots to show my settings.
20141202-browser-screenshot.png
20141202-htdocs-location.png
20141202-MAMP-htdocs-settings.png
20141202-php-ini-settings.png
0
GaryCommented:
I suspect you are editing the wrong php.ini file
Do a phpinfo() and check the paths.
0
Richard Coffree-commerce Product ManagerAuthor Commented:
When I did the phpinfo(), the version displayed is 5.6.2 so I took the php.ini located in the 5.6.2 directory.
But I will re-check it asap.
0
GaryCommented:
Under Loaded Configuration File it will show where it is being loaded from
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard Coffree-commerce Product ManagerAuthor Commented:
I use the Gary comment to find the correct location of the php.ini and I used the function trigger_error() provided by Ray to test several cases of cases.

Thank a lot guys.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.