Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #1459 > unrolled thread
| Started by | bill <nobody@spamcop.net> |
|---|---|
| First post | 2011-05-07 07:27 -0400 |
| Last post | 2011-05-07 18:34 +0200 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.lang.php
evaluating a null value in an array bill <nobody@spamcop.net> - 2011-05-07 07:27 -0400
Re: evaluating a null value in an array Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-07 07:36 -0400
Re: evaluating a null value in an array Gregor Kofler <usenet@gregorkofler.com> - 2011-05-07 18:35 +0200
Re: evaluating a null value in an array dougatmilmacdotcom@example.com (Doug Miller) - 2011-05-07 23:46 +0000
Re: evaluating a null value in an array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-08 13:56 +0200
Re: evaluating a null value in an array Gregor Kofler <usenet@gregorkofler.com> - 2011-05-08 20:18 +0200
Re: evaluating a null value in an array bill <nobody@spamcop.net> - 2011-05-07 13:50 -0400
Re: evaluating a null value in an array Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-05-07 15:30 +0000
Re: evaluating a null value in an array Gregor Kofler <usenet@gregorkofler.com> - 2011-05-07 18:34 +0200
| From | bill <nobody@spamcop.net> |
|---|---|
| Date | 2011-05-07 07:27 -0400 |
| Subject | evaluating a null value in an array |
| Message-ID | <5uWdnXAptq8EsVjQnZ2dnUVZ_sidnZ2d@cablespeedmi.com> |
I have an array of values, one of which might be null. This statement fails if ( ($dos <= $insInfo[3]) or($dos == '0000-00-00')) with the error: Notice: Undefined offset: 3 in /var/www/MP2010-v2/classes/cDollar.php on line 237 when $insInfo[3] is NULL. I figured I could shortcut the evaluation with: if ( ( is_null($insInfo[3])) or($dos <= $insInfo[3]) or($dos == '0000-00-00')) but I get the same error. I sure would appreciate: knowing why I get the error, and a suggestion on how to evaluate this value. bill
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2011-05-07 07:36 -0400 |
| Message-ID | <iq3asi$cn8$1@dont-email.me> |
| In reply to | #1459 |
On 5/7/2011 7:27 AM, bill wrote: > I have an array of values, one of which might be null. > > This statement fails > if ( ($dos <= $insInfo[3]) or($dos == '0000-00-00')) > > with the error: > Notice: Undefined offset: 3 in /var/www/MP2010-v2/classes/cDollar.php on > line 237 > > when $insInfo[3] is NULL. > > I figured I could shortcut the evaluation with: > > if ( ( is_null($insInfo[3])) or($dos <= $insInfo[3]) or($dos == > '0000-00-00')) > > but I get the same error. > > I sure would appreciate: > knowing why I get the error, and > a suggestion on how to evaluate this value. > > bill Is it null, or is it not set? There is a difference! Try isset() instead of is_null(). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2011-05-07 18:35 +0200 |
| Message-ID | <iq3scb$gre$2@dont-email.me> |
| In reply to | #1461 |
Am 2011-05-07 13:36, Jerry Stuckle meinte: > On 5/7/2011 7:27 AM, bill wrote: >> I have an array of values, one of which might be null. >> >> This statement fails >> if ( ($dos <= $insInfo[3]) or($dos == '0000-00-00')) >> >> with the error: >> Notice: Undefined offset: 3 in /var/www/MP2010-v2/classes/cDollar.php on >> line 237 >> >> when $insInfo[3] is NULL. >> >> I figured I could shortcut the evaluation with: >> >> if ( ( is_null($insInfo[3])) or($dos <= $insInfo[3]) or($dos == >> '0000-00-00')) >> >> but I get the same error. >> >> I sure would appreciate: >> knowing why I get the error, and >> a suggestion on how to evaluate this value. >> >> bill > > Is it null, or is it not set? There is a difference! Which isset() won't spot. http://php.net/manual/de/function.isset.php Gregor -- http://vxweb.net
[toc] | [prev] | [next] | [standalone]
| From | dougatmilmacdotcom@example.com (Doug Miller) |
|---|---|
| Date | 2011-05-07 23:46 +0000 |
| Message-ID | <iq4lkp$aad$1@dont-email.me> |
| In reply to | #1468 |
In article <iq3scb$gre$2@dont-email.me>, Gregor Kofler <usenet@gregorkofler.com> wrote: >Am 2011-05-07 13:36, Jerry Stuckle meinte: >> On 5/7/2011 7:27 AM, bill wrote: >>> I have an array of values, one of which might be null. >>> >>> This statement fails >>> if ( ($dos <= $insInfo[3]) or($dos == '0000-00-00')) >>> >>> with the error: >>> Notice: Undefined offset: 3 in /var/www/MP2010-v2/classes/cDollar.php on >>> line 237 >>> >>> when $insInfo[3] is NULL. >>> >>> I figured I could shortcut the evaluation with: >>> >>> if ( ( is_null($insInfo[3])) or($dos <= $insInfo[3]) or($dos == >>> '0000-00-00')) >>> >>> but I get the same error. >>> >>> I sure would appreciate: >>> knowing why I get the error, and >>> a suggestion on how to evaluate this value. >>> >>> bill >> >> Is it null, or is it not set? There is a difference! > >Which isset() won't spot. Nonetheless, isset() is the right function to use here. is_null($x) fails if $x is not set; isset($x) does not.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2011-05-08 13:56 +0200 |
| Message-ID | <2043173.lGaqSPkdTl@PointedEars.de> |
| In reply to | #1468 |
Gregor Kofler wrote:
> http://php.net/manual/de/function.isset.php
In this international newsgroup (and maybe elsewhere), it is probably better
to suggest
<http://php.net/isset>
This takes advantage of several features of the PHP.net Web site:
- The mirror will be chosen according to the visitor's geographic
location (or their preferences), which should provide them with the
fastest/most desirable viewing experience;
- The language will be chosen according to visitor preferences (cookies)
(although it must be said that the English version is apparently the
most accurate and up-to-date one);
- Whenever the documentation structure changes, relevant information
can still be found; either through implicit redirection, or through
the search results being displayed for parts of the documentation
where redirection is not implemented.
Therefore, I have found this bookmarklet useful:
http://php.net/%s
Regards,
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
[toc] | [prev] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2011-05-08 20:18 +0200 |
| Message-ID | <iq6mpo$goh$1@dont-email.me> |
| In reply to | #1474 |
Am 2011-05-08 13:56, Thomas 'PointedEars' Lahn meinte: > Gregor Kofler wrote: > >> http://php.net/manual/de/function.isset.php > > In this international newsgroup (and maybe elsewhere), it is probably better > to suggest > > <http://php.net/isset> Indeed. I normally both use and suggest the English version of the manual. Googling for a quick link gave me the German version, and I didn't pay enough attention. Gregor
[toc] | [prev] | [next] | [standalone]
| From | bill <nobody@spamcop.net> |
|---|---|
| Date | 2011-05-07 13:50 -0400 |
| Message-ID | <NLSdncSh7MTxG1jQnZ2dnUVZ_v-dnZ2d@cablespeedmi.com> |
| In reply to | #1461 |
On 5/7/2011 7:36 AM, Jerry Stuckle wrote: > On 5/7/2011 7:27 AM, bill wrote: >> I have an array of values, one of which might be null. >> >> This statement fails >> if ( ($dos <= $insInfo[3]) or($dos == '0000-00-00')) >> >> with the error: >> Notice: Undefined offset: 3 in >> /var/www/MP2010-v2/classes/cDollar.php on >> line 237 >> >> when $insInfo[3] is NULL. >> >> I figured I could shortcut the evaluation with: >> >> if ( ( is_null($insInfo[3])) or($dos <= $insInfo[3]) or($dos == >> '0000-00-00')) >> >> but I get the same error. >> >> I sure would appreciate: >> knowing why I get the error, and >> a suggestion on how to evaluate this value. >> >> bill > > Is it null, or is it not set? There is a difference! > > Try isset() instead of is_null(). Exactly, when I use isset it does not error. Thanks. bill
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denis.m.f.mcmahon@gmail.com> |
|---|---|
| Date | 2011-05-07 15:30 +0000 |
| Message-ID | <4dc5658b$0$31951$bed64819@gradwell.net> |
| In reply to | #1459 |
On Sat, 07 May 2011 07:27:21 -0400, bill wrote:
> a suggestion on how to evaluate this value.
if (
!(isset($insInfo[3])) // $insInfo3 not defined
|| (is__null($insInfo[3])) // $insInfo3 defined and null
|| ($dos <= $insInfo[3]) // $insInfo3 > $dos
|| ($dos == '0000-00-00') // $dos null date
)
Rgds
Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2011-05-07 18:34 +0200 |
| Message-ID | <iq3saq$gre$1@dont-email.me> |
| In reply to | #1466 |
Am 2011-05-07 17:30, Denis McMahon meinte: > On Sat, 07 May 2011 07:27:21 -0400, bill wrote: > >> a suggestion on how to evaluate this value. > > if ( > !(isset($insInfo[3])) // $insInfo3 not defined > || (is__null($insInfo[3])) // $insInfo3 defined and null Not necessary. isset() also returns false when the tested variable is set to NULL [1]. $bar = NULL; var_dump(isset($foo)); // FALSE var_dump(isset($bar)); // FALSE Gregor [1] http://php.net/manual/de/function.isset.php -- http://vxweb.net
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web