Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107281 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14475 invoked from network); 21 Sep 2019 16:47:58 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 21 Sep 2019 16:47:58 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 7F7FE2D1FE9 for ; Sat, 21 Sep 2019 07:26:06 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36351 199.187.172.0/22 X-Spam-Virus: No Received: from tbjjbihbhebb.turbo-smtp.net (tbjjbihbhebb.turbo-smtp.net [199.187.174.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Sat, 21 Sep 2019 07:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.net; s=turbo-smtp; x=1569680766; h=DomainKey-Signature:Received: Received:MIME-Version:References:In-Reply-To:From:Date: Message-ID:Subject:To:Cc:Content-Type; bh=mSjv2vuyr/5sX700zRttfq 3WMdMCvULkQZ5PBdCXjHw=; b=fgDcclLD8nSTwX4h/rK4w0b44R2DVTLT7qW3Kc QlAXmDMgkypJg6AnSR/2YWWHn+wRdET17N3k+Gik4drd4fY5a+kNBiustWYbhG+b eDBIVCHgGbeM1FWOnowuHDXF1jXF37EAPRVrUyQ3vDD24/m3HlG30hhsw9anCwX3 Ac5F0= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=turbo-smtp; d=php.net; h=Received:Received:X-TurboSMTP-Tracking:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version:References:In-Reply-To:From:Date:X-Gmail-Original-Message-Id:Message-ID:Subject:To:Cc:Content-Type; b=eMbbUQRg8hJ7/5ypMxvxkNobT/5ibZG3J1pVrkucrf+00qwCCikmJXHOD6fuGs +EAb8ANAuPmDhTTp73A2eBRmRSbpzkVOx/G52UPNT0pPonJ/XniGWiHRUamEHZPX aT9igcuvi3zr5WaI3MRkg6+Y6D0TXe9iaKwqJ/Qbb+4aU=; Received: (qmail 27147 invoked from network); 21 Sep 2019 14:26:05 -0000 Received: X-TurboSMTP-Tracking: 5297917619 X-Gm-Message-State: APjAAAVuSerDV0TYT9MI7pdLqr9YqIaJkOC8dZkbVeES0VkTs52JltZ7 iL4++wgv7plMQd9hIS2fx70Fo4o4+0D9yhTglzM= X-Google-Smtp-Source: APXvYqzLS2BNjom3smb7xCyEPgxSOLi6SOD63O4LLDjJr5kqkulbSHn+RzDAQO5lZanZthrv5m5sVKuWRX8jrrBtzdA= X-Received: by 2002:a37:4750:: with SMTP id u77mr4646289qka.68.1569075964828; Sat, 21 Sep 2019 07:26:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 21 Sep 2019 17:25:53 +0300 X-Gmail-Original-Message-Id: Message-ID: To: Kosit Supanyo Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary="000000000000826344059310f77c" X-Envelope-From: Subject: Re: [PHP-DEV] Question about `global` variable declaration From: zeev@php.net (Zeev Suraski) --000000000000826344059310f77c Content-Type: text/plain; charset="UTF-8" On Sat, Sep 21, 2019 at 3:09 PM Kosit Supanyo wrote: > I understand your point but inconsistency in my sense is syntactical By > comparing to other declaration syntax like `var`, `static`, 'public` an > others. They allow only T_VARIABLE but `global` is different. And there's > another way to archive the same goal through `$GLOBALS`, that's why I see > it as inconsistency. > Even though we're dealing with archeology here - this really isn't an inconsistency but intended behavior. Unlike var, public, static and others - 'global' is not a declaration of class structure, but a way to access global variables. In the same way it sometimes makes sense to access variables indirectly ($$foo), it may sometimes make sense to access global variables indirectly (global $$foo). It allows for both creation and access of global variables. It doesn't sound very useful or practical to provide that ability for the creation of dynamic class properties, which is why it's not available for var/public/static/etc. Zeev --000000000000826344059310f77c--