Re: Assignment in Conditional - How are they evaluated?
| From: | Martin Scotta | Date: | Thu, 29 Oct 2009 14:07:34 +0000 |
| Subject: | Re: Assignment in Conditional - How are they evaluated? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299499@lists.php.net to get a copy of this message | ||
On Thu, Oct 29, 2009 at 10:58 AM, Mark Skilbeck <markskilbeck@gmail.com>wrote:
> How is the following evaluated:
>
> [code]
> if ($data = somefunc()) ...
> [/code]
>
> Ignoring the 'assignment inside condition' arguments, is the return value
> of somefunc() assigned to $data, and then $data's value is evaluated (to
> true or false), or is the actual assignment tested (does the assignment
> fail, etc)?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
The code is interpreted this way...
$data = somefunc();
if ($data)
--
Martin Scotta