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