<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed><type>rich</type><version>1.0</version><provider_name>phorkie</provider_name><provider_url>https://p.cweiske.de/</provider_url><title>PHP: Assign and use a variable in "if" with "&amp;&amp;"</title><author_name>Christian Weiske</author_name><cache_age>86400</cache_age><width>900</width><height>900</height><html>&lt;!-- embedding all files of https://p.cweiske.de/591 --&gt;
&lt;link rel="stylesheet" href="https://p.cweiske.de/css/embed.css"/&gt;
&lt;div class="phork" id="591"&gt;
    &lt;div class="phork-file"&gt;
 &lt;div class="phork-content"&gt;
  &lt;div class="code"&gt;&lt;pre class="txt"&gt;&amp;lt;cweiske&amp;gt;       Hi. Why do I get a PHP notice when I define a variable and then use it in the second part of a &amp;quot;&amp;amp;&amp;amp;&amp;quot;?&#13;
&amp;lt;cweiske&amp;gt;       $b = 2 &amp;amp;&amp;amp; $b;&#13;
&amp;lt;cweiske&amp;gt;       PHP Notice:  Undefined variable: b in php shell code on line 1&#13;
&amp;lt;cweiske&amp;gt;       afterwards it is defined&#13;
&amp;lt;Derick&amp;gt;        cweiske: this is a typical &amp;quot;undefined behaviour&amp;quot; case. Doesn't work in C as you expect either.&#13;
&amp;lt;cweiske&amp;gt;       (my actual code was: if ($client = get_client() &amp;amp;&amp;amp; $client-&amp;gt;is_active)&#13;
&lt;/pre&gt;&lt;/div&gt;

 &lt;/div&gt;
 &lt;div class="phork-meta"&gt;
  &lt;a href="https://p.cweiske.de/591/rev-raw/088b4a4829bcee7815d5ff84339fbb1d26845dcc/phork0.txt" style="float: right"&gt;view raw source&lt;/a&gt;
  &lt;a href="https://p.cweiske.de/591#phork0.txt"&gt;phork0.txt&lt;/a&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</html></oembed>
