Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73876 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15393 invoked from network); 4 May 2014 16:28:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2014 16:28:20 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.47 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.220.47 mail-pa0-f47.google.com Received: from [209.85.220.47] ([209.85.220.47:61418] helo=mail-pa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/21-05809-2AA66635 for ; Sun, 04 May 2014 12:28:18 -0400 Received: by mail-pa0-f47.google.com with SMTP id fa1so8100750pad.20 for ; Sun, 04 May 2014 09:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:mime-version:in-reply-to:content-type :content-transfer-encoding:message-id:cc:from:subject:date:to; bh=1TKKzpxmRcl+spKPV8LYVT/K9IguXCSitL39GTJcv9o=; b=wGYKsue8rWFwu/r7QG+yA0gSdrJirhezxTXjbX2Vo/FLobvkZKrp2VBuCPEFgfX7cF ByVSm8TkZDBmJO4pnUn26ytdtyeld9VuAX/Qnoj1PIanDKlz4oqZc6IUqtJmcE0T6cJL ZdtLWcx6Ip4FVK956Pfe6qzKI3iEMMxbSqzjQ79CtCG51CaZ+dYBSdCiMP3kwHAhIcRb iG/6Mk3ghr8w+8+ta19CEeb5qB0HmXUwc+RN27jiZ753FLt8/nWsfb4yKZIVcyQWd1cV eCc2e8C1GgNQlCVjL37stGnbOPeNB2NQvfbQIqaVYuhEtI0TRzS0y7LiaaP4on5xO54m 3VTA== X-Received: by 10.66.254.198 with SMTP id ak6mr61299692pad.156.1399220894914; Sun, 04 May 2014 09:28:14 -0700 (PDT) Received: from [10.82.110.181] ([14.100.132.173]) by mx.google.com with ESMTPSA id qh2sm48823167pab.13.2014.05.04.09.28.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 04 May 2014 09:28:13 -0700 (PDT) References: <1399216437.14925.0.camel@localhost.localdomain> <1399218363.5851.40.camel@guybrush> Mime-Version: 1.0 (1.0) In-Reply-To: Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: quoted-printable Message-ID: Cc: "internals@lists.php.net" X-Mailer: iPhone Mail (11D201) Date: Mon, 5 May 2014 00:28:08 +0800 To: Aaron Lewis Subject: Re: [PHP-DEV] Is it possible to get the variable name from the HashTable structure? From: tjerk.meesters@gmail.com (Tjerk Meesters) Hi, > On 4 May, 2014, at 11:54 pm, Aaron Lewis wrot= e: >=20 > FWD I forgot to CC the list ;-( >=20 > ---------- Forwarded message ---------- >=20 >=20 > Here's what I want, >=20 > If a user runs code like this, and $_GET['MH'] happens to be > undefined, I want to know both '_GET' and 'MH': I suppose you could compare the hash table against the few super globals the= re are :) >=20 > if ($_GET['MH'] =3D=3D 'dog') > { > do-something > } >=20 > 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 ) >=20 >=20 >=20 > On Sun, May 4, 2014 at 11:46 PM, Johannes Schl=A8=B9ter > 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, >>>>=20 >>>> So PHP uses HashTable to store variables like $_POST, >>>>=20 >>>> =46rom a HashTable structure, can I get the array name? >>=20 >> 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.) >>=20 >> If you know the parent such hacks like >>=20 >>> https://gist.github.com/krakjoe/50603be7ffb1ae6e9156 >>=20 >> 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. >>=20 >> 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. >>=20 >> johannes >=20 >=20 >=20 > -- > Best Regards, > Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ > Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33 >=20 >=20 > --=20 > Best Regards, > Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ > Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20