Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99673 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4553 invoked from network); 29 Jun 2017 09:08:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2017 09:08:43 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:36842] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/F8-07609-A93C4595 for ; Thu, 29 Jun 2017 05:08:42 -0400 Received: by mail-wm0-f53.google.com with SMTP id 62so76023779wmw.1 for ; Thu, 29 Jun 2017 02:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=EA8lR0i0zrCpdFIJLVV6eh+BZ+iKiA2wNquenUWEyGM=; b=nNY0Ps+kj47kixbTDPX6yiJ/IoT7qjbR7Mpwf+XdSAYK2zmj3jhriTQApunaC4/T6o veZsYTagWoT0thaAA0Bbqmka8PsZmRwDQoCUB/lhx+PwfRmL2IfS01uQChAuIC6AS+D2 ndUx5B2yjr9eCZTVH1eT/21+tqgi8OrEb5/U8H+XnyWrPUxs3zuzZGs94XqwE16/KlQ2 +kWTIuw7nSG3LjDZDzeaBTiIwrB/XEEiIaUFA2DGjODEC3ioW9VzVexDhMj5bCqgGZ5l XYSNraNwGnLMFLJcPczR33R7c27JZac4EcLgo7nBtxuWWX/Cr5QdTojrFsKqG2hJetUe BAsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=EA8lR0i0zrCpdFIJLVV6eh+BZ+iKiA2wNquenUWEyGM=; b=f93iTNe1QFBLWZEzuLwqlIgvjNEAHoKVQihANeUJCUzvNXz5uuTgczmplTzcu/wL5a dyUjHAp/AA/8yhnXj4gjFzqZBR9ujkYvmyo4FDrJsO28YiXd73kQx1UTo5VPR3+CuYPQ C4wzHPcbWV7Q31pk8DSG/Vc6iSRD3zVzIP161Pdi8QIQx9FbwAHOnKxwqI83WEasmK2A yrlNZqq5x/A5EkRrfWKFYG/QWX4+NU5B8T1JQm1mUELeF7XjVhpkh70meSdlez2K1e/q F82c/j+y39lSpLK0bAtIkjV444AD11Z3SFudU+8lNFadmGpFFc/0nj/zi53d94bUq7kQ OjXQ== X-Gm-Message-State: AKS2vOwDiuNkzdrRPeuOtlCQ0/kDYlqIlIkC7/7xdU1txrNupOy0yBLq Ya7IVk9uvn6V6iAQWBNqlew8aVj8a4va X-Received: by 10.28.230.89 with SMTP id d86mr11112464wmh.80.1498727319752; Thu, 29 Jun 2017 02:08:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.161.155 with HTTP; Thu, 29 Jun 2017 02:08:39 -0700 (PDT) Received: by 10.223.161.155 with HTTP; Thu, 29 Jun 2017 02:08:39 -0700 (PDT) In-Reply-To: References: Date: Thu, 29 Jun 2017 11:08:39 +0200 Message-ID: To: lists@rhsoft.net Cc: PHP Internals List Content-Type: multipart/alternative; boundary="001a1147c4b0825bea055315a537" Subject: Re: [PHP-DEV] Final variables From: ocramius@gmail.com (Marco Pivetta) --001a1147c4b0825bea055315a537 Content-Type: text/plain; charset="UTF-8" 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. 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 > > --001a1147c4b0825bea055315a537--