Re: Mixed return type - boolean and array/resource/closure or object
| From: | Aziz Saleh | Date: | Tue, 04 Mar 2014 00:05:07 +0000 |
| Subject: | Re: Mixed return type - boolean and array/resource/closure or object | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323017@lists.php.net to get a copy of this message | ||
On Mon, Mar 3, 2014 at 6:24 PM, Robert Stoll <php@tutteli.ch> wrote:
> Hey Aziz
>
>
>
> Thanks for your response, but you got my question wrong.
>
> I wonder if there is a built-in function which returns one of the depicted
> combinations.
>
> Like strpos which returns either int or false (Boolean)
>
>
>
> Cheers,
>
> Robert
>
>
>
> *From:* Aziz Saleh [mailto:azizsaleh@gmail.com]
> *Sent:* Tuesday, March 04, 2014 12:20 AM
> *To:* Robert Stoll
> *Subject:* Re: [PHP] Mixed return type - boolean and
> array/resource/closure or object
>
>
>
>
>
>
>
> On Mon, Mar 3, 2014 at 6:10 PM, Robert Stoll <php@tutteli.ch> wrote:
>
> Heya,
>
> I would like to know if a PHP built-in function/method exists which
> returns one of the following combinations
> - a boolean or an array
> - a boolean or a resource
> - a boolean or a closure
> - a boolean or an object
>
> I searched in the language manual, but it is quite hard to be honest since
> there is not really an overview.
> Please get back to me if you are certain that there is not such a
> function/method or give me an example if there is one.
>
> Cheers,
> Robert
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> All of what you need can be found here (is_bool, is_resource, is_object,
> is_array)
> http://www.php.net/manual/en/ref.var.php
>
> The closure is just an object of type Closure, so is_object($object) &&
> get_class($object) == 'Closure' should be sufficient to check for closures.
>
> Aziz
>
Hi Robert,
Sorry I hit reply instead of reply all.
Afaik, there isn't a function that would do what you need. You will need to
make your own implementation containing the combination you need.
Aziz