Re: Re: [PATCH] Notice on array to string convertion
| From: | Etienne Kneuss | Date: | Wed, 02 Nov 2011 10:41:04 +0000 |
| Subject: | Re: Re: [PATCH] Notice on array to string convertion | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56008@lists.php.net to get a copy of this message | ||
Hi,
On Wed, Nov 2, 2011 at 09:55, Laruence <laruence@php.net> wrote:
> On Mon, Oct 31, 2011 at 10:55 AM, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
>> Hi!
>>
>>> Hi:
>>> like the following script:
>>> <?php
>>> $str = (string)array();
>>> echo $str;
>>>
>>> it is obviously intentionally convert a array to string , but the
>>> warning is coming:
>>
>> I think it's the correct way to react for PHP. This code is an extremely
>> convoluted way to write "echo 'Array';" and as such doesn't seem
>> to do
>> anything useful. I have yet to see one single instance where converting
>> array to string made any sense. Of course,
>>
>> As for the warning in 60174, it seems to be a bug indeed - the code there
>> has no business converting any arrays to strings and in general the engine
>> shouldn't apply make_printable_zval to arrays knowingly - there's no useful
>> result that can come from that as far as I can see. So if you know more of
>> such cases lease point them out and they should be fixed.
> #60198 Array to string notice from array functions
>
> Some of the array_* functions that compare elements in multiple arrays do so by
> (string)$elem1 === (string)$elem2.
>
> If $elem1 or $elem2 is an array, then the array to string notice is thrown.
>
> https://bugs.php.net/bug.php?id=60198
>
> thanks
In such cases, the notice actually seems fine to me. This is typically
the cases where you want to inform the user that he probably did
something wrong...
>
>> --
>> Stanislav Malyshev, Software Architect
>> SugarCRM: http://www.sugarcrm.com/
>> (408)454-6900 ext. 227
>>
>
>
>
> --
> Laruence Xinchen Hui
> http://www.laruence.com/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Etienne Kneuss
http://www.colder.ch