FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Please help clear up some php error notice issue?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Please help clear up some php error notice issue? [message #180039 is a reply to message #180036] Sat, 29 December 2012 04:37 Go to previous messageGo to previous message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma:
Member
On Fri, 28 Dec 2012 22:12:53 -0500, BobMCT <r(dot)mariotti(at)fdcx(dot)net>
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.

I don't know the solution to your problem. There may be something
terribly simple about it that I do not understand (I am a relative
beginner at php) . However, if I had that problem I would try to
approach it systematically. For instance:

What happens if you place a reference to one of those error prompting
variables immediately after the line where you are setting the
variable to ''?

Does the error occur? If it does, then what happens if you set it to
something besides ''? If you cannot get the if(!isset... line to
prevent the error in a referencfe immediately following it, then post
THAT here.

If it DOES prevent the error then the subsequent reference to the
variable is:

1. not actually after the if(!isset...line, or
2. is not the same variable, or
3. is within a function without access to the original set value, or
4. has been unset somewhere between the start and the error.

Without your whole script these 4 cannot be evaluated.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Current PHP implementation
Next Topic: Create SQLite3 Version of PHP Manual from Docbooks
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 02:33:59 GMT 2024

Total time taken to generate the page: 0.04487 seconds