Silence “Declaration … should be compatible” warnings in PHP 7

1. Workaround Since it is not always possible to correct all the code you did not write, especially the legacy one… if (PHP_MAJOR_VERSION >= 7) { set_error_handler(function ($errno, $errstr) { return strpos($errstr, ‘Declaration of’) === 0; }, E_WARNING); } This error handler returns true for warnings beginning with Declaration of which basically tells PHP that … Read more

PHP7.1 json_encode() Float Issue

This drove me nuts for a bit until I finally found this bug which points you to this RFC which says Currently json_encode() uses EG(precision) which is set to 14. That means that 14 digits at most are used for displaying (printing) the number. IEEE 754 double supports higher precision and serialize()/var_export() uses PG(serialize_precision) which … Read more

Switch php versions on commandline ubuntu 16.04

Interactive switching mode sudo update-alternatives –config php sudo update-alternatives –config phar sudo update-alternatives –config phar.phar Manual Switching From PHP 5.6 => PHP 7.1 Default PHP 5.6 is set on your system and you need to switch to PHP 7.1. Apache: $ sudo a2dismod php5.6 $ sudo a2enmod php7.1 $ sudo service apache2 restart Command Line: … Read more