Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108017 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12736 invoked from network); 7 Jan 2020 02:06:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jan 2020 02:06:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9AEF9180505 for ; Mon, 6 Jan 2020 16:11:12 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2063.outbound.protection.outlook.com [40.92.40.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 6 Jan 2020 16:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GuxW7hdWtZxD0yPFp2qwTQf0zomLdNUItEwo8jCecdda2+U3V6DvHeOUMx7byy0HKSH1S0BwjWLgeyU6kkoKWuxEW0YfNx2C9glE2EvBNjO0ACdoNnpiydUulH3dNbkv2vCpEnhEUj72/o7f9XQpIZE9JVRtjTRZB2imDnXIEC+mPsf8gpSyXTeo9xLnUI41jZdyGRwlS8g95mz/IBt7Vq/cgIfawdNxEuNl/GpVfdxMS6jkDy1C3Lw9bdUXnDV3s+u9mwYJTsv7cCOQ4sorlJbthGIVu40v++u+1Ra5VnXNxUMszV7b6QZF+DWvKUpKtbmZhH3n5eCmAEGm6QF2Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3ksZr7H6GhOSllin7kNSlf+nC6nrMGQAxvGce9xvoP8=; b=WDHNeF4EESb/CL0ujAQ0sBPeV+5CYvOw8zl/Dn7PhJ42YPfd3a+6aTWugbt8MiKSkT/p2cXHrQcVBAyrTYpSs9wkK8QL1j3KGhMH6dOaAy2tGo2S7dX7Ow17BTOBxJFps6LtiXaG8TF+KsKa9ZtxsLKLIdiRJq5WB+p1rUDOJ4pBuRLgDV4/uPsCbqTWg3mA8XR9QjrINlVSzRjyH/sb8xnmwIokSvXSE0g5rfjMojhOLrw8LxWsk8ztTCq3bfmRabM0OuFgtmFZRjQZZATbpja/CfxwS/moC9zVjM/PkSpobyaO2vuidSVMcSXbluRGdHJn+dPyGwQzEMVL9btctA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3ksZr7H6GhOSllin7kNSlf+nC6nrMGQAxvGce9xvoP8=; b=qH5lsw7qn/gpBQlSuNDTtsttvPPLIvXK/kdmtak85iV9Pc0aB8fkF/wM/E8EXCkTIk7AulQ+hLyJNAVl2n7kiijCGRRmJ/R4SGkfn0pC5Q/HkToBmPAYf9SGg/pu9F0Tdch5FxB6Skq2hsNv1g81CGfxAwDR0VQ0ZMkLTrQCjPEshnW5m0m5NjR+E6EutzMZ/vbI6R0UZbVodF++tu5+Fe9RhfUJmmkhi79WL1TWuhYRT7PaV8TG//0sJkt3hbBFNZckW+L8g7Y8/v80lbNi2rZ08Yz7SSzTPrWOz3HoFE/zQC4+UlQsbfiODdGQWa0KNK/kAtbzV2slD+BNddpsgQ== Received: from BN7NAM10FT068.eop-nam10.prod.protection.outlook.com (10.13.156.55) by BN7NAM10HT125.eop-nam10.prod.protection.outlook.com (10.13.156.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Tue, 7 Jan 2020 00:11:09 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com (10.13.156.58) by BN7NAM10FT068.mail.protection.outlook.com (10.13.156.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Tue, 7 Jan 2020 00:11:09 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::29e3:53bf:163e:5beb]) by DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::29e3:53bf:163e:5beb%3]) with mapi id 15.20.2602.016; Tue, 7 Jan 2020 00:11:09 +0000 To: Rowan Tommins , "internals@lists.php.net" Thread-Topic: [PHP-DEV] Initializing constants once, with code? Thread-Index: AQHVwZMGVGGpEwzQ00OYU/q+965QOqfcl9gCgADlCgCAAKjxAIAAHwMAgAARm1Q= Date: Tue, 7 Jan 2020 00:11:09 +0000 Message-ID: References: <5e0d723f.1c69fb81.e2ae8.24e2SMTPIN_ADDED_MISSING@mx.google.com> <74F2DBFC-E63C-428C-A37F-2D0CEE15AD0F@newclarity.net> <8D8F3E7E-137E-459B-B13A-9C7940731243@newclarity.net>, In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:77699B16CC873F3C9FD5DE2A0EBEA6266630A519392C629F161691255542938C;UpperCasedChecksum:3FA688E5570822E6D46E28C76D5433890F2FB0B6104CEB1FA3DB59EEFD058DC6;SizeAsReceived:7455;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [PGjpSs3KVJIfBiG4XHIl7aGCnStthlyk5yHmIR4sb+oGJUBK4lclkNkTp3FCysRI] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 923a2e8a-ab4c-4e41-44f9-08d793061943 x-ms-traffictypediagnostic: BN7NAM10HT125: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AS7qdSPqmKArp93BvamsFni9wfQhw3Nc/A5j4/O9xoFEwmeFU0mLMqzV1NMo1mYRfWDb0T4d9aj+Kwng55TqHJLCAqpwBrW4UzLZKlWxS5Sfva3jo3zrBIFcq/7q2gomO+lLxuwlYEhKr5fDasQjrYY9InduuqJOr1MUZEWKR6DgSiSnX9ySuMubBBN9ZKW2 x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 923a2e8a-ab4c-4e41-44f9-08d793061943 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jan 2020 00:11:09.8690 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT125 Subject: Re: [PHP-DEV] Initializing constants once, with code? From: tysonandre775@hotmail.com (tyson andre) =0A= > const DEBUG_MODE =3D false;=0A= > =0A= > function foo() {=0A= > if (DEBUG_MODE) {=0A= > // Do stuff.=0A= > }=0A= > }=0A= > =0A= > PHP will currently (AIUI) inline the DEBUG_MODE value at compile time,=0A= > notice that the code path is unreachable, and omit it from the compiled o= pcodes entirely.=0A= > (I'm pretty sure it does that now, at least; if not, it certainly can be.= )=0A= =0A= It actually can't do that safely for global constants.=0A= (But it can and does do that for class constants, *within the class*)=0A= For example, if you declare a constant twice (declare() or const DEBUG_MODE= =3D), then php emits a notice, but continues executing keeping the value t= he constant previously had.=0A= You can use opcache's debug output to confirm that.=0A= =0A= php -d zend_extension=3Dopcache.so -d opcache.enable_cli=3D1 \=0A= -d opcache.file_cache=3D -d opcache.opt_debug_level=3D0x20000 example.ph= p=0A= =0A= ```=0A=