Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73877 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19683 invoked from network); 4 May 2014 17:34:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2014 17:34:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:57186] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/00-18762-73A76635 for ; Sun, 04 May 2014 13:34:48 -0400 Received: from [192.168.2.31] (ppp-93-104-30-37.dynamic.mnet-online.de [93.104.30.37]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 1C4D4468A5; Sun, 4 May 2014 19:35:41 +0200 (CEST) To: Aaron Lewis Cc: internals@lists.php.net In-Reply-To: References: <1399216437.14925.0.camel@localhost.localdomain> <1399218363.5851.40.camel@guybrush> Content-Type: text/plain; charset="UTF-8" Date: Sun, 04 May 2014 19:34:22 +0200 Message-ID: <1399224862.5851.52.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: Fwd: [PHP-DEV] Is it possible to get the variable name from the HashTable structure? From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Sun, 2014-05-04 at 23:54 +0800, Aaron Lewis wrote: > 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'] == '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 ) What do you want to achieve? Some developer tool for better messages? For the general case of $someVar->method()['key1']['key2'] == 'baz' there is no good solution (well, you could try to analyze the current opcode array, try to find current opline in there and do magic, but that's quite crazy and notable effort) For the simple case you can look at Joe's example on how to iterate over the current symbol table, and if need be combine that with a recursive search (mind infinite recursion caused by references) but there the effort makes it questionable whether the information gained brings value ... johannes