Can someone explain this line of code please? (Logic & Assignment operators)
<p>I've seen the following lines of code and I know what they do, but I don't know how the second line works (and hence how to apply it to another situation).</p>

<pre><code>$user = User::model()-&gt;findByPk(123);
empty($user-&gt;profile) and $user-&gt;profile = new Profile();
</code></pre>

<p>The code tries to look up the User from the database, and if there isn't a profile, creates a new for use later on.</p>

<p>I have also seen code before that goes something like the following:</p>

<pre><code>$variable1 = $variable2 = $variable3;
</code></pre>

<p>It did something a bit more complex than simple assigning three things to be the same, but I'm finding it impossible to search for this type of thing to find out any information about it, let alone find the original code that I came across. I think it originally had an 'and' in there somewhere. Does anyone know how to search for code that has more than one equals sign in it that wasn't just an if statement?</p>

<p>Sorry for the two questions in one (and vague at that) and the terrible title (I'll fix it up when I know what the names are, if it's anything like a tenary statement)).</p>
