Re: Declare minimum PHP version required?
| From: | Johannes Schlüter | Date: | Mon, 03 Feb 2014 22:09:41 +0000 |
| Subject: | Re: Declare minimum PHP version required? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72139@lists.php.net to get a copy of this message | ||
On Tue, 2014-02-04 at 04:46 +0900, Yasuo Ohgaki wrote:
> I may be worried to much, but I don't like run time environment checks
> which evaluated over and over. There are many codes that checks PHP
> version, loaded extension, library version, etc to make sure code works as
> it should be. Perhaps, more generic form might be better
>
> declare('requirements') {
> if (version_compare(PHP_VERSION, '5.6.0', '<')) {
> echo 'You need PHP 5.6.0 or later';
> return FALSE;
> }
> if (!extension_loaded('foo')) {
> echo 'You need foo extension';
> return FALSE;
> }
> // and so on
> return TRUE;
> }
>
That still has to run each time the file is included.
johannes