Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14682
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Matthew Carter <m@ahungry.com> |
| Newsgroups | comp.lang.php |
| Subject | Re: Consistency with object to boolean conversions |
| Date | Wed, 03 Dec 2014 11:42:49 -0500 |
| Organization | Ahungry (http://ahungry.com) |
| Lines | 61 |
| Message-ID | <87d280ofau.fsf@ahungry.com> (permalink) |
| References | <m5n8a7$gra$1@dont-email.me> <m5n9l9$djm$1@solani.org> <m5narg$rvn$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="7c986cd4736462de309a749b207746fe"; logging-data="12853"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Lb9v8UHk9WvnRdEWdDYFU" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| Cancel-Lock | sha1:nY6PzQvvjA2wST5ZuQgGJXmCV6o= sha1:bZdL5txxfQ7KiHi7NzXIBMgqATE= |
| Xref | csiph.com comp.lang.php:14682 |
Show key headers only | View raw
Gregor Kofler <usenet@gregorkofler.com> writes:
> Am 2014-12-03 um 16:19 schrieb Christoph M. Becker:
>> 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.
>>>
>>> Catchable Fatal Error: Object of class
>>> Symfony\Component\HttpFoundation\File\UploadedFile could not be
>>> converted to boolean in
>>> /var/www/strbase_client/src/Strbase/ClientBundle/Controller/BatchController.php
>>> line 54"
>>>
>>> Why does the object to boolean conversion in the if condition in line 50
>>> *not* cause an error?
>>
>> What gets printed when you change line 51 to:
>>
>> var_dump($file);}
>>
>> I guess that answers your question.
>
>
> Erm... no. Line 51 is not reached - hence I get precisely the same
> output as above.
> $file exists and is a UploadedFile instance.
>
>
This works for me:
class a {}
$b = new a ();
if (!$b)
{
}
else
{
echo '$a is an object!';
var_dump (!$b);
}
Maybe its an issue related to your specific class?
--
Matthew Carter (m@ahungry.com)
http://ahungry.com
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