Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73875 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12296 invoked from network); 4 May 2014 15:54:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2014 15:54:36 -0000 Authentication-Results: pb1.pair.com header.from=the.warl0ck.1989@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=the.warl0ck.1989@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.180 as permitted sender) X-PHP-List-Original-Sender: the.warl0ck.1989@gmail.com X-Host-Fingerprint: 209.85.214.180 mail-ob0-f180.google.com Received: from [209.85.214.180] ([209.85.214.180:57517] helo=mail-ob0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/C0-05809-AB266635 for ; Sun, 04 May 2014 11:54:35 -0400 Received: by mail-ob0-f180.google.com with SMTP id va2so4619708obc.25 for ; Sun, 04 May 2014 08:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=LCtATG+cSh4Psx4CHRu8v5OKwdpRtFb7bc2XhAnvStg=; b=aTtwFqu1oek23JHeMqFgV0GJuxu+DZxwGttUZUvmQNiQT/kesqYc2+TZcEY8+9Uq+E uKqbiPnN//z3KRfwfsJECTF0Fx6RV1Z4UDYS0S6gesZqTHLliiFbpBGmK4YFQocVJ4WJ pIT9CK7Lv75nZ/9TFkYeJ/gaqGPN0UigTf3uZc0PvixdIooXfy/9MnUVofs6o2sW2Ugg GFPHOPSi4Ks3c6/q5GHgEzJLRvCi3TStNKXoKI84ZfxkU9EG36hf8/S5qOt3TlB+iREV SAekM1Dt1UC8WroDjOTMwUrqbicuAcmy1/i1XmpMYB3RTGasZyT3uiSj3ohP2+thkqHS 5bhQ== MIME-Version: 1.0 X-Received: by 10.182.219.167 with SMTP id pp7mr174921obc.85.1399218872166; Sun, 04 May 2014 08:54:32 -0700 (PDT) Received: by 10.76.23.66 with HTTP; Sun, 4 May 2014 08:54:32 -0700 (PDT) In-Reply-To: References: <1399216437.14925.0.camel@localhost.localdomain> <1399218363.5851.40.camel@guybrush> Date: Sun, 4 May 2014 23:54:32 +0800 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Fwd: [PHP-DEV] Is it possible to get the variable name from the HashTable structure? From: the.warl0ck.1989@gmail.com (Aaron Lewis) FWD I forgot to CC the list ;-( ---------- Forwarded message ---------- Here's what I want, If a user runs code like this, and $_GET['MH'] happens to be undefined, I want to know both '_GET' and 'MH': if ($_GET['MH'] =3D=3D 'dog') { do-something } But so far I can only get the 'MH' part ( I checked the 'Undefined index' part in a zend function, can't remember the exact name ) On Sun, May 4, 2014 at 11:46 PM, Johannes Schl=C3=BCter wrote: > On Sun, 2014-05-04 at 16:13 +0100, Joe Watkins wrote: >> On Sun, 2014-05-04 at 20:21 +0800, Aaron Lewis wrote: >> > Hi, >> > >> > So PHP uses HashTable to store variables like $_POST, >> > >> > From a HashTable structure, can I get the array name? > > No, a zval (which might point to a hash tale) doesn't refer to a name. > For one there in 99.99% is no need but it would cost memory(and CPU > cycles to maintain) and then there miht e multiple nae (references) or > none (temporaries etc.) > > If you know the parent such hacks like > >> https://gist.github.com/krakjoe/50603be7ffb1ae6e9156 > > might work, but even this solution is flawed: The easy thing it doesn't > support is references, it should return an array of all names. It won't > work for complex things, though. > > If you need such a functionality I'd suggest to take a step back and > think what you actually want to do ... usually there is a better > solution. > > johannes > > -- Best Regards, Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33 --=20 Best Regards, Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33