recently i had the necessity of use come code for backward compatibility with PHP 5.6 and i did this using if statement, checking php version for choosing what code execute. This is a little example:
if ( version_compare( PHP_VERSION, '7.0', '>=' ) ) {
return strtotime($b['date']) <=> strtotime($a['date']);
}
else {
if (strtotime($a['date']) == strtotime($b['date'])) {
return 0;
}
return (strtotime($a['date']) > strtotime($b['date'])) ? -1 : 1;
}
I thought that this would be sufficient, but it's not. PHP is still trying to execute the PHP 7 code, returning an error with the spaceship operator. Anyone know why php is still executing code inside and if statement that clearly says to not do that and how to solve this? Thank you
Aucun commentaire:
Enregistrer un commentaire