Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51868 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39815 invoked from network); 11 Apr 2011 19:08:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Apr 2011 19:08:21 -0000 Authentication-Results: pb1.pair.com header.from=truth@proposaltech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=truth@proposaltech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain proposaltech.com from 98.139.53.194 cause and error) X-PHP-List-Original-Sender: truth@proposaltech.com X-Host-Fingerprint: 98.139.53.194 nm10-vm0.bullet.mail.ac4.yahoo.com Received: from [98.139.53.194] ([98.139.53.194:44549] helo=nm10-vm0.bullet.mail.ac4.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/12-24294-4A153AD4 for ; Mon, 11 Apr 2011 15:08:20 -0400 Received: from [98.139.52.196] by nm10.bullet.mail.ac4.yahoo.com with NNFMP; 11 Apr 2011 19:08:18 -0000 Received: from [98.138.90.56] by tm9.bullet.mail.ac4.yahoo.com with NNFMP; 11 Apr 2011 19:08:18 -0000 Received: from [98.138.89.250] by tm9.bullet.mail.ne1.yahoo.com with NNFMP; 11 Apr 2011 19:08:17 -0000 Received: from [127.0.0.1] by omp1042.mail.ne1.yahoo.com with NNFMP; 11 Apr 2011 19:08:17 -0000 X-Yahoo-Newman-Id: 984465.49650.bm@omp1042.mail.ne1.yahoo.com Received: (qmail 81486 invoked from network); 11 Apr 2011 19:08:17 -0000 Received: from [192.168.2.102] (truth@75.79.135.173 with login) by smtp105.sbc.mail.ne1.yahoo.com with SMTP; 11 Apr 2011 12:08:17 -0700 PDT X-Yahoo-SMTP: jWG9jiaswBBOCHlPTWD9zJWRnNyiDJE- X-YMail-OSG: t9c0HH8VM1lTX79IqLO1JhZW5yAn4INzgkw83fGp4PvIs2P RpZ54yPpaQ7OXu0X1.LDNn.YPWOi3De6i2vVVZfYYrLsiapiBEkKM2HE6LZE rWNdGI1arWWVg46IVPAFIhgRXrcmeygIkLImbJWv_ybq5kTR4vb.dp6jdb0L XqhTEwqkpaOOT.iR6gN6U1lYmpQVzYLNjviY86WBtmTVQII4.SpvxZvosril 7eW1RTXq2R7dhULuMB5NV5RVPXYHqJwwU_y9h0Ib7kuk8yHbNZbMa42cQYaX ITarRW2aNKh0emWjgR4195QkVXeskyDazdjdH6oiwdxsrRRNKlS9G5HpJ_d_ Vqjpx1xc8QrUH3kM0vI_stqXnFxTuD5D5mA-- X-Yahoo-Newman-Property: ymail-3 Reply-To: truth@proposaltech.com To: Internals Mailing List In-Reply-To: <4DA3468E.8000509@sugarcrm.com> References: <4DA26602.6080303@lorenso.com> <20110411133657.GK7113@crousti> <4DA3468E.8000509@sugarcrm.com> Content-Type: text/plain; charset="ISO-8859-1" Date: Mon, 11 Apr 2011 12:08:15 -0700 Message-ID: <1302548895.15421.18.camel@inspiron> Mime-Version: 1.0 X-Mailer: Evolution 2.30.1.2 Content-Transfer-Encoding: 7bit Subject: Avoiding "Undefined index" notices From: truth@proposaltech.com (Todd Ruth) I'm not arguing whether the following code fragment is good or bad (it's certainly less than ideal), but given the recent threads, I thought I'd show how I feel I've been encourage by php to code: I'm not sure where (if anywhere) that technique is documented or even if it should be documented, but if you want to avoid "Undefined index" notices, that's one of the more terse approaches. The relative brevity is more obvious when the variable names are long and $temp is re-linked several times before unsetting. It's probably less clear than alternatives unless you see it often. Here is an application to the defaults for configurations thread: It isn't beautiful, but it avoids writing "$config[$param]" more than once and it avoids the notices. - Todd