How find errors in [PHP 5.6 files] converted to PHP 7.2

I plan to migrate to NEW SERVER VPS that support only 7.1/7.2 PHP

How to find errors in [PHP 5.6 files] converted to PHP 7.2…???

I have VS2019com/VS Code, Eclipse PHP 2019.06, Atom, …

How in Eclipse IDE open a [5.6] PHP file as PHP 7.2…? so show errors

Hi @mymac1, are you looking for a PHP linter that would highlight the errors in your code editor?
In any case the best way to be sure there are no errors is to try it out and test it thoroughly on the target version of PHP you will be running. A linter can ease the task but you should not rely on it as there may be errors it will not be able to pick up.


I would start by creating a local development environment with php 7. Pull down the code and run the website. Start combing through the error log and fixing things page by page. Once you get the website to at least display the home page than continue going through the website functionality manually to test everything again page by page. You might be able to automate some of this with static analysis but you will still need to do most of it manually to assure the website actually works. The most obvious change is php 7 removes mysql_. If the website uses those functions all that needs to be rewritten using pdo or mysqli_ instead.

1 Like


Install Xdebug on your development environment.
Every error and warning will show clearly on-screen, complete with a stack trace.


Find the default php.ini settings using the following file and beware that they change when PHP is upgraded, also the default Online setting should be different and not display_errors:


declare(strict_types=1); // APPLIES TO THIS FILE ONLY
// SHOULD BE SET IN php.ini  // applies to this file and all include/require files  
  // error_reporting(-1); // MAXIMUM ERRORS
  // ini_set('display_errors'. '1');  // LOCALHOST ONLY

$title = 'Local PHP enviromnent';

$envs = [
      error_reporting() ,
$tbl = '<div><table>';
  $tbl .= '<h1>' .$title .'</h1>';
  for( $key=0; $key<count($envs); $key++):
    $tbl .= '<tr>';
      $tbl .= '<td>' .$envs[$key]   .'</td>';
      $tbl .= '<td>' .$envs[++$key] .'</td>';
    $tbl .= '</tr>';  
$tbl .= '</table></div>' ;

<!doctype html><html><head lang="en-GB">
<title> <?= $title ?> </title>  
  div   {text-align:center;}  
  table { display: inline-block; margin:0 auto;}  
  tr    {text-align: left;}
  th    {border:solid 1px #ccc; padding: 0.12em 0.88em;}  
  <?= $tbl ?>

Learn about declare(strict_types=1); because it fails fast and immediately pinpoints errors which should be displayed on the screen.

PHP has an excellent online manual and errors easily browsed: declare(strict_types=1) error_reporting(-1) ini_set('display_errors); ini_get('display_errors);

Use Firefox and install the following Validation Tool:

Try Sublime Browser - currently free with popup reminders.

Hopefully when display_errors is set to ‘0’ and error_reporting(-1); then PHP errors should be saved in php_error.log - find out where the log is located.

A good IDE like PhpStorm it would tell you everything that is wrong instead of having to jump through hoops trying to find problems. There ae probably plugins available for several of the editors you listed. There are also numerous code analyzers available as well.Google is your friend.

2 posts were split to a new topic: What is strict types in PHP about?

PHP 5.6 is mostly compatible with 7. The primary concern is mysql_* functions. The mysql_* functions have been removed in 7. So you will need to update the code to use either PDO or mysqli which are backward compatible. That is if the 5.6 code uses that but even in 5.6 mysql_* functions are deprecated. The other caveat is going to be extensions. If you are using any extensions in 5.6 that don’t have a 7 counterpart than things will become tricky. The other one is call time pass by reference which was removed in 5.4. So I assume you don’t need to deal with that. Otherwise 5.6 & 7 should be mostly compatible. 7 adds some really nice features but also is mostly backward compatible with 5.4+. That said I agree with using source control and having separate branches. Version control and git are an important thing to know. Version control and git is something that can be applied to any language.