Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14686
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Consistency with object to boolean conversions |
| Date | 2014-12-03 18:09 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <m5ng47$k3d$1@dont-email.me> (permalink) |
| References | <m5n8a7$gra$1@dont-email.me> <m5neof$125$6@dont-email.me> |
Am 2014-12-03 um 17:46 schrieb Denis McMahon:
> On Wed, 03 Dec 2014 15:56:23 +0100, Gregor Kofler wrote:
>
>> The following example should suffice to describe my problem:
>>
>> 50 if(!$file) {
>> 51 }
>> 52 else {
>> 53 echo '$file is an object.';
>> 54 var_dump(!$file);
>> 55 }
>>
>> results in
>>
>> "$file is an object.
>
> Try casting file to boolean:
>
> 54 var_dump(!(boolean)$file);
>
> and see if that works as you expected.
>
Without testing I assume it would yield the same result. Found a
possible explanation here
https://bugs.php.net/bug.php?id=65213
it still doesn't explain why casting to boolean in the if condition
doesn't throw an error.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Consistency with object to boolean conversions Gregor Kofler <usenet@gregorkofler.com> - 2014-12-03 15:56 +0100
Re: Consistency with object to boolean conversions "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-03 16:19 +0100
Re: Consistency with object to boolean conversions Gregor Kofler <usenet@gregorkofler.com> - 2014-12-03 16:39 +0100
Re: Consistency with object to boolean conversions Matthew Carter <m@ahungry.com> - 2014-12-03 11:42 -0500
Re: Consistency with object to boolean conversions Gregor Kofler <usenet@gregorkofler.com> - 2014-12-03 18:06 +0100
Re: Consistency with object to boolean conversions Matthew Carter <m@ahungry.com> - 2014-12-03 13:13 -0500
Re: Consistency with object to boolean conversions Denis McMahon <denismfmcmahon@gmail.com> - 2014-12-03 16:46 +0000
Re: Consistency with object to boolean conversions Gregor Kofler <usenet@gregorkofler.com> - 2014-12-03 18:09 +0100
Re: Consistency with object to boolean conversions "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-03 18:22 +0100
Re: Consistency with object to boolean conversions Gregor Kofler <usenet@gregorkofler.com> - 2014-12-03 19:12 +0100
Re: Consistency with object to boolean conversions "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-03 19:30 +0100
Re: Consistency with object to boolean conversions Gregor Kofler <usenet@gregorkofler.com> - 2014-12-03 20:58 +0100
csiph-web