Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7970

Re: Please help clear up some php error notice issue?

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Please help clear up some php error notice issue?
Date 2012-12-28 23:32 -0500
Organization A noiseless patient Spider
Message-ID <kblrph$gbo$1@dont-email.me> (permalink)
References <jdnsd8halp443u3n0r3eem0asdjcsr6rab@4ax.com>

Show all headers | View raw


On 12/28/2012 10:12 PM, BobMCT wrote:
> Since upgrading to version 5.4.x I've been seeing a common error
> complaining about undefined variables.
> I know that the E_Notice can be suppressed but I want to eliminate the
> cause as well.
>
> To address this issue I've added statements at the beginning of the
> code to determine if the named variable is set and if not to set it to
> null.  This should then satisfy this complaint.
>
> Here is what this code typically looks like:
>
> if  (!isset($Usage)) { $Usage = ''; }
> if  (!isset($_userid)) { $_userid = ''; }
> if  (!isset($_userno)) { $_userno = ''; }
> if  (!isset($V0)) { $V0 = ''; }
>
> So my understanding is that references to any/all of the above defined
> variables should NOT cause that error notice.  However, it seems to
> continue.
>
> Without going bonkers would some of you who understand this somewhat
> syntactical issue please try to explain the best way to handle this
> issue so me and I'm sure many, many other php developers can once and
> for all rid outselves of this so common issue?
>
> Thanks.
>

Well, first of all, if this is the top of the code, then you really 
don't need the if statement - all non-superglobals (i.e. not $_GET, 
$_SESSION, etc.) will be undefined.  The only exception would be if 
you're running with register_globals enabled in your PHP configuration, 
which it should NOT be.

However, you didn't show us the code that's causing your problem, so 
there's not much more we can do to help you.

Try posting the entire code that's failing with the applicable messages 
and we can take a closer look at it.

P.S. Congratulations on trying to write good code.  Too many programmers 
are sloppy in their writing, creating potential problems later.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Please help clear up some php error notice issue? BobMCT <r.mariotti@fdcx.net> - 2012-12-28 22:12 -0500
  Re: Please help clear up some php error notice issue? Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-28 23:32 -0500
  Re: Please help clear up some php error notice issue? Richard Yates <richard@yatesguitar.com> - 2012-12-28 20:37 -0800
  Re: Please help clear up some php error notice issue? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-12-29 10:26 +0100

csiph-web