Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107282 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24217 invoked from network); 21 Sep 2019 17:40:14 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 21 Sep 2019 17:40:14 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id A9BCD2D1FCA for ; Sat, 21 Sep 2019 08:18:22 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) (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 08:18:22 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id e11so8653285otl.5 for ; Sat, 21 Sep 2019 08:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wBZkgm2BbX3lTQjkDRJSug82tmQPa93SrIkq1lS93rQ=; b=hlwDFdokTUuWqbdoY1ldTna4kkZJHYlo9QHhWi1y1rOgkBEYVUF45AF9uqS06O/CtB UlZjqtHqzqN03bnlQcp1cgBbeNHoWg2RNWsKqPzVGFDEwrIuVXSyTVgFFOmCdPM7kKWK rnCY/i5Xtaa3//FQGsr09SIVzIs2Kfgyh/8yjmuXkz8p7GYw75vc0gb4WLQMO4HeDM/I DlN++zeTzPJGHDHA6oqrPw36gFtCoVUlCxnBmgWKdJQGnNPWb3ZQ3OPkpaw0Ex4t+BvB b/yju6/AFiUrfLi6SsZjs2nAXeROgcFdlCf+8Ycx3lXOiJHnPa2uoiSbt5UuhXxtteLt LYqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wBZkgm2BbX3lTQjkDRJSug82tmQPa93SrIkq1lS93rQ=; b=A2uZCAbqSJPd7YafAsnZMHkBS+ascJ4nLzT8/43czMIrR4fz8OJrDnIH+5vk1JCDVr xr7PoOzcuBh4zUp3tAo3aHqndfbRuJkV+iQ6kKzvXHi3u7HMIe+qVGS9h3ViR36WsMK5 eVcFfeKtVYx3CWW5pHnnn2TnbMUz0yTmhdelWTfCtpNIdjrfif3IAb76M2JqtjhzO9uv FM2Do8zZznJTcWgxGbzh4uDJe/jwjzAv+/1ILzQQPPZRPbzmb8ZFdrCnUzKcPUBZmCsQ ZIJW5vq7DRKg6bn3EhOEpEeMgFvWxEGvLO7yUSVSb813ZiqqzzUq6XbvbwmUkokr+Nor 9a8Q== X-Gm-Message-State: APjAAAUD9FbDtVKEET+OLHRu/mRRU+YpRKS9oOo5VYP2hZlKuRKhDvap BQ0qTEvxz6HlavkudNDSAF6/e+QZN4cfmn+VlruDR6eU X-Google-Smtp-Source: APXvYqwagbBcAE+gjp+jjU4EEYkmeZzkRKPo1GqdbHmCWSU+Qmwns2tqmd65QlFoRxRKvsJMPQXDon+W3vmDCRaotk4= X-Received: by 2002:a9d:3a5:: with SMTP id f34mr16198326otf.4.1569079101408; Sat, 21 Sep 2019 08:18:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 21 Sep 2019 22:18:10 +0700 Message-ID: To: Zeev Suraski Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000076cc34059311b250" X-Envelope-From: Subject: Re: [PHP-DEV] Question about `global` variable declaration From: webdevxp.com@gmail.com (Kosit Supanyo) --00000000000076cc34059311b250 Content-Type: text/plain; charset="UTF-8" > > Unlike var, public, static and others - 'global' is not a declaration of > class structure, but a way to access global variables. I know it is not and I think almost everyone knows that. As I said, I came up with this by comparing to other declarations syntactically not functionally, it is inconsistent in that way. I don't know how many PHP developers out there know `global` can take variable variables but I my guess is, very very little because there's no information about this behavior of `global` in PHP manual https://www.php.net/manual/en/language.variables.scope.php and I'd never seen those forms of `global` in any projects/articles before. Cheers On Sat, Sep 21, 2019 at 9:26 PM Zeev Suraski wrote: > 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 > --00000000000076cc34059311b250--