PHP Classes

Use one php program for php 5 and 7

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Use one php program for php 5 and 7  
Subject:Use one php program for php 5 and 7
Summary:Guard code
Author:Barton Phillips
Date:2021-09-02 16:57:04
Update:2021-10-12 07:39:23

  1. Use one php program for php 5 and 7   Reply   Report abuse  
Picture of Barton Phillips 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.

There are 2 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.

Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.

For more information send a message to info at phpclasses dot org.