Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72080 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50158 invoked from network); 3 Feb 2014 11:15:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2014 11:15:06 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.204 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.204 mail4.serversure.net Linux 2.6 Received: from [217.147.176.204] ([217.147.176.204:54786] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/B2-35654-83A7FE25 for ; Mon, 03 Feb 2014 06:15:05 -0500 Received: (qmail 32723 invoked by uid 89); 3 Feb 2014 11:15:02 -0000 Received: by simscan 1.3.1 ppid: 32717, pid: 32720, t: 0.0593s scanners: attach: 1.3.1 clamav: 0.96/m:52 Received: from unknown (HELO linux-dev4.lsces.org.uk) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 3 Feb 2014 11:15:01 -0000 Message-ID: <52EF7ADA.8090001@lsces.co.uk> Date: Mon, 03 Feb 2014 11:17:46 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0 SeaMonkey/2.23 MIME-Version: 1.0 To: internals@lists.php.net References: <52EF4BF8.60005@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: lester@lsces.co.uk (Lester Caine) Yasuo Ohgaki 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. I don't see how one can eliminate checking if a module is available. I do not load MySQL on my systems so if someone tries to run a script requiring MySQL they need a warning that it's not available. The build of PHP running ensures that the available built in modules are of the right version, but it's the third party libraries that I need to ensure are compatible with the version of PHP I'm trying to run, and that the necessary extensions for that library are loaded. Stuff updated to PHP5.5 may not work on the systems that are still running PHP5.4 for compatibility reasons ... -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk