PHP Errors On Blank Page

Hi Experts,

I just upgraded from PHP 5.6 to 7.1

On PHP 5.6 when I had a PHP error mid-page it still showed my elements that came before the error, such as my print_r  output, which helped in troubleshooting, but now with PHP 7.1 it hides everything and shows the error on a blank page.

How can I show the prior elements?

Thanks
APD TorontoAsked:
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.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Likely you hit a problem with a deprecated API, which has been promoted from warning to fatal in PHP 7.X+ versions.

Enable WP_DEBUG + visit a page + look for Fatal in your debug.log file.

Likely something simple to fix.

I was imagining you're using WordPress. If not, then you'll have to enable debugging, based on your runtime environment + look for logging... likely in Apache's error.log file.
0
NerdsOfTechTechnology ScientistCommented:
What I like to do is EXIT the code until the error occurs. This helps with both debugging errors or isolating deprecated code.

<?php
x=1;
echo $x . '<br>';
exit;
// good code ran above without fatal because the code execution STOPS with exit so the next line and below doesn't run
echo $x echo echo $x . '<br>'; 
$x =2;
%>

Open in new window

Then just move the exit line downward to isolate error(s)!:
<?php
x=1;
echo $x . '<br>';
echo $x echo echo $x . '<br>'; // this line runs now. ERROR thrown and found!
exit;
$x =2;
%>

Open in new window


http://php.net/manual/en/function.exit.php
0
APD TorontoAuthor Commented:
This is not a WP site. I was thinking it is an ini setting
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

NerdsOfTechTechnology ScientistCommented:
How can I show the prior elements?

OPTION #1 (if you have Root access):
Look at your error logs as David Favor mentioned.

Most likely the log is in a common location; however, I would check the location of the log file first.

I was thinking it is an ini setting
It Is.

You can look in php.ini or run a quick php file you can upload and test temporarily (then delete):
<?php phpinfo(); ?>

Open in new window


Look for the location of the error log in the error_log entry. Once you find the file, go to that directory and read the file. Note: This may not work on a shared hosting environment (e.g. error_log is blank); in this case, use option #2.

OPTION #2 (if you have FTP access only OR are in a shared environment with no error log):
'step' through the code using a strategically placed
exit;

Open in new window

line as I mentioned before.
0
APD TorontoAuthor Commented:
I think that we are talking about 2 different things. I know where my error log is.

If you refer to my original post, I am asking how to display the html elements and all rendered data before the error? With PHP 5, I could see images, texts, different form elements right until the error occurred. Now, if there is an error, nothing is displayed, but the error.
0
NerdsOfTechTechnology ScientistCommented:
All of your code before the exception should show, so it is possible that the exception is occurring before any output (unless it is a fatal).

What did your log say the exception was?

In PHP 7, use try/catch, to pinpoint the new PHP 7 Throwable class:
try{
     // ALL of your code here
} 
catch(Throwable $e) {
    $trace = $e->getTrace();

    echo $e->getMessage().' in '.$e->getFile().' on line '.$e->getLine().' called from '.$trace[0]['file'].' on line '.$trace[0]['line'];

    // $bt = debug_backtrace(); 
    // print_r($bt);
}

Open in new window

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