![Picture of Barton Phillips Picture of Barton Phillips](/picture/user/592640.png)
Barton Phillips - 2021-09-02 16:57:04
How can I guard my code so I can run the same program on PHP 5 and 7. For example in php 7 I can do $x = $x ?? 'true';
In php 5 I have to do $x = $x ? null : 'true';
I have tried using PHP_MAJOR_VERSION but when I put the ?? in the php 7 only if/else I get a Parser Error. It seems that there must be a way to guard certain areas of the code so it can be run on either php 5 or 7.