Re: Declare minimum PHP version required?

From: Date: Mon, 03 Feb 2014 10:55:27 +0000
Subject: Re: Declare minimum PHP version required?
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Stas,

On Mon, Feb 3, 2014 at 4:57 PM, Stas Malyshev <[email protected]>wrote:

> > The same thing can be done by version_compare() and die(), but it does
> not
> > make much sense executing script only to check PHP version and die,
> > especially for libraries. For library, it is preferred to fail when it is
>
> Why not? That's what PHP does - executing scripts.
>
> > included, not when it is executed. I wouldn't write version_compare() and
>
> I don't understand - what is the difference? In PHP including and
> executing is the same thing.
>
> I think version_compare works just fine.


I works, but it requires CPU time for it and evaluation is delayed at
run time, not compile time. Isn't it nice to know requirement is not met?

We may extend declare() more. For example, loaded extensions.

declare(module='pgsql,openssl');

With this, we could eliminate code like

if (!extension_loaded('foo')) {
  die('You need foo module');
}
if (!extension_loaded('bar')) {
  die('You need bar module');
}

With opcache loaded extension check may be completely skipped.

Evaluation at compile time and run time differs.

Regards,

--
Yasuo Ohgaki
[email protected]


Thread (50 messages)

« previous php.internals (#72076) next »