RE: [PHP] Re: ramble was [PHP] Not sure of my error
| From: | jeremy brand | Date: | Sat, 18 Nov 2000 01:25:57 +0000 |
| Subject: | RE: [PHP] Re: ramble was [PHP] Not sure of my error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26001@lists.php.net to get a copy of this message | ||
I guess, the issue seems to be when variables are undeclared and then
you check them.
I often never have these problems (on purpose) because when I am
afraid that I will run into a situation like this, I declare my
variable ahead of time to a default value. Nothing like being
absolutely sure, and this guarantees is. I guess this just comes from
my C days.
In my opinion, if you don't want to have errors on undeclared
variables, then the only way to be sure you are not going to get
errors is to declare them!
:)
-jeremy brand
Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: jeremy@nirvani.net
http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html
for more
- - - - - - - - - - - - - - - - - - - - - - - - -
I am pleased to see that we have differences. May we together become
greater than the sum of both of us.
-- Surak of Vulcan, "The Savage Curtain", stardate 5906.4
On Fri, 17 Nov 2000, jeremy brand wrote:
> Date: Fri, 17 Nov 2000 17:21:06 -0800 (PST)
> From: jeremy brand <jeremy@nirvani.net>
> To: Matt Stone <matt@planetveggie.com>
> Cc: Philip Olson <philip@theprojects.org>, Joe Stump <joe@earth.care2.com>,
php-general@lists.php.net
> Subject: RE: [PHP] Re: ramble was [PHP] Not sure of my error
>
> This is good for integer values.
>
> If it is zero (0) then it is false, anything else and it is true. If
> you have a string in $foo, then you must accept what happens when the
> automatic variable conversion takes place.
>
> To do !$foo on a string doesn't even make sense.
>
> -jeremy brand
>
> Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: jeremy@nirvani.net
> http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for
> more
> - - - - - - - - - - - - - - - - - - - - - - - - -
> I am pleased to see that we have differences. May we together become
> greater than the sum of both of us.
> -- Surak of Vulcan, "The Savage Curtain", stardate 5906.4
>
>
> > What about just:
> >
> > if(!foo) {
> > //bla
> > }
> >
> > are there any problems with this?
> >
> > -----Original Message-----
> > From: jeremy brand [mailto:jeremy@nirvani.net]
> > Sent: Saturday, 18 November 2000 11:15 AM
> > To: Philip Olson
> > Cc: Joe Stump; Matt Stone; php-general@lists.php.net
> > Subject: Re: [PHP] Re: ramble was [PHP] Not sure of my error
> >
> >
> > On our production servers, we run with no error reporting. This makes
> > the most sense, given our situation.
> >
> > -jeremy brand
> >
> > Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: jeremy@nirvani.net
> > http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html
> > for more
> > - - - - - - - - - - - - - - - - - - - - - - - - -
> > I am pleased to see that we have differences. May we together become
> > greater than the sum of both of us.
> > -- Surak of Vulcan, "The Savage Curtain", stardate 5906.4
> >
> > On Sat, 18 Nov 2000, Philip Olson wrote:
> >
> > > Date: Sat, 18 Nov 2000 01:14:53 +0000 (GMT)
> > > From: Philip Olson <philip@theprojects.org>
> > > To: Joe Stump <joe@earth.care2.com>
> > > Cc: Matt Stone <matt@planetveggie.com>, php-general@lists.php.net
> > > Subject: Re: [PHP] Re: ramble was [PHP] Not sure of my error
> > >
> > > > No - it's up to you. Don't use empty() for checking numbers because it
> > will
> > > > return true if set to 0 - that's my only advice.
> > >
> > > *nods* although :
> > >
> > > if ($foo == '0')
> > > {
> > > echo 'sup';
> > > }
> > > // will check whatever but 0
> > > elseif (empty($foo))
> > > {
> > > echo 'it';
> > > }
> > > else
> > > {
> > > echo 'err';
> > > }
> > >
> > > anyway, is it true that if error checking is set to 'high' that a check
> > > such as :
> > >
> > > if ($foo == '')
> > >
> > > will or could return an error? i am looking but cannot find this again
> > > but remember seeing it in a post about a month ago. not 100% certain but
> > > would like to be :-)
> > >
> > > philip
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > > For additional commands, e-mail: php-general-help@lists.php.net
> > > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> > >
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>