Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99674 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7014 invoked from network); 29 Jun 2017 09:19:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2017 09:19:13 -0000 Authentication-Results: pb1.pair.com header.from=lists@rhsoft.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=lists@rhsoft.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain rhsoft.net designates 91.118.73.15 as permitted sender) X-PHP-List-Original-Sender: lists@rhsoft.net X-Host-Fingerprint: 91.118.73.15 mail.thelounge.net Received: from [91.118.73.15] ([91.118.73.15:31491] helo=mail.thelounge.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/79-07609-F06C4595 for ; Thu, 29 Jun 2017 05:19:12 -0400 Received: from srv-rhsoft.rhsoft.net (Authenticated sender: h.reindl@thelounge.net) by mail.thelounge.net (THELOUNGE MTA) with ESMTPSA id 3wyvHJ16GgzXMn for ; Thu, 29 Jun 2017 11:19:08 +0200 (CEST) To: PHP Internals List References: Message-ID: <54e9e9f4-1fda-d7db-61a4-2a1574005a79@rhsoft.net> Date: Thu, 29 Jun 2017 11:19:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-CH Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Final variables From: lists@rhsoft.net ("lists@rhsoft.net") Am 29.06.2017 um 11:08 schrieb Marco Pivetta: > Final is about having immutable data. Immutable doesn't mean that it's a > system wide constant, it means that it's referentially pure in its scope. i refered to "why you would forcefully need it to be a variable still then if you know the value is gonna be constant" and as long constants in PHP are a) very expensive and b) "const" pretends to be compile time which is provable wrong with my sample code are terrible to use in other languages like Visual Basic constants are fast, in PHP they are slow, both in define and access > On 29 Jun 2017 11:05 AM, "lists@rhsoft.net " > > wrote: > > > > Am 29.06.2017 um 04:50 schrieb Kalle Sommer Nielsen: > > 2017-06-28 20:46 GMT+02:00 David Rodrigues > >: > > The "final" keyworks make a "local scope" variable value > "blocked to > rewrite" after instantiate it. > Okay, it sounds like a "const", and it is, but "not as we > known it". > > > I get that, but I still don't understand why you would > forcefully need > it to be a variable still then if you know the value is gonna be > constant, of course besides global visibility or in iterations > > > because constants are expensive in PHP when "define()" is a function > call and "const" is very limited for no good reason > > "no good reason" because if it really would be compile time the > following won't work and so why can't you use 'const' within a > if-statement when you in fact can CONCAT two with define() set > constant which are part of a if-statement themself > ____________________________________________________ > > if(PHP_SAPI !== 'cli') > { > define('MY_PHP_SELF', $_SERVER['SCRIPT_NAME']); > define('rh_serverurl', PROTOCOL_PREFIX . MY_SERVER_NAME . $rh_port); > } > else > { > define('MY_PHP_SELF', '/' . basename($_SERVER['SCRIPT_NAME'])); > define('rh_serverurl', 'http://localhost'); > } > const rh_phpself = rh_serverurl . MY_PHP_SELF; > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >