Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72109 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15929 invoked from network); 3 Feb 2014 19:47:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2014 19:47:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.48 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:34496] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/AE-35654-932FFE25 for ; Mon, 03 Feb 2014 14:47:06 -0500 Received: by mail-la0-f48.google.com with SMTP id mc6so5642627lab.7 for ; Mon, 03 Feb 2014 11:47:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=bccC8+06//DNdETrHsPbsUnbMtaM5sVYAI2u6XDl4Lg=; b=ZTYVaclRkhJLWgYQg/qGyTaNIngc/z/qlgvqRBhC2zgbcx1fh4ggp0+IzRrdKzY/yk ag2xBef67b9TtGl1zHpbu4z983mh0xswibhFbIcqQyH6TRF/Txaj5Fx3kzLNz5Lva88V MpGxGjU3mYzfC/reJjApAMMFMUV+WhzUXH/8P+a9pd4BhOqKMeSLIc+3O0AixSHByiN1 4GEvfc0j2RGSmf9TJUO84/My6qhmOMn0aJQ/uDRhJez8Js7wLozyOOZpIl6bu9ef2P3l /650JkatOgFKyKnCt2hWk0hTTUK9apw2frghRkl+vy+2poBhZPjYk/+jfzyPNMIiUrsY wR8g== X-Received: by 10.153.3.2 with SMTP id bs2mr26313186lad.5.1391456822856; Mon, 03 Feb 2014 11:47:02 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Mon, 3 Feb 2014 11:46:22 -0800 (PST) In-Reply-To: References: Date: Tue, 4 Feb 2014 04:46:22 +0900 X-Google-Sender-Auth: m92C8QIs60_JVwGx24vWmJEHxPk Message-ID: To: Sara Golemon Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1136c742a5938a04f185c98c Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1136c742a5938a04f185c98c Content-Type: text/plain; charset=UTF-8 Hi Sara, On Tue, Feb 4, 2014 at 3:14 AM, Sara Golemon wrote: > On Sun, Feb 2, 2014 at 10:58 PM, Yasuo Ohgaki wrote: > > I thought it might be good for us to have declaring minimum PHP version > > required to execute script. > > http://jp1.php.net/manual/en/control-structures.declare.php > > > > Something like > > > declare(php_version>='5.6.0'); > > // or PHP_VERSION_ID? using = as minimum as it could be a little faster > > // and no change in declare() syntax. > > declare(php_version=50600); > > > While I like it from a formality stand-point, I have to agree with > Stas. The is entirely doable as PHP code right now. Include time IS > execute time. And if you're concerned with a single integer compare > in your perf analysis, you're probably worried about the wrong thing. 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; } for example. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1136c742a5938a04f185c98c--