<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1044522" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1044522</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Thanks. Since I&#039;m using not</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/little-php-help-multiple-if-conditions#comment-1244078</link>
    <description> &lt;p&gt;Thanks. Since I&#039;m using not equal, the &amp;amp;&amp;amp; is actually the right way to do it. When you&#039;re IFing on &quot;doesn&#039;t equal&quot; things get counterintuitive... so in the past I&#039;ve ended up with an always true condition.&lt;br /&gt;
With &quot;&amp;amp;&amp;amp;&quot; (or equivalent) it works because any $type that isn&#039;t &quot;contentype1&quot; or &quot;contentype2,&quot; will return true for both &quot;doesn&#039;t equal&quot; tests.&lt;/p&gt;
&lt;p&gt;In short, when you&#039;re working &quot;doesn&#039;t equal&quot; you achieve &quot;isn&#039;t either...or...&quot; by coding &quot;isn&#039;t... and isn&#039;t...&quot;&lt;/p&gt;
 </description>
     <pubDate>Thu, 06 Aug 2009 15:31:52 +0000</pubDate>
 <dc:creator>aharown07</dc:creator>
 <guid isPermaLink="false">comment 1244078 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>aharown07 wrote:
Conditional</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/little-php-help-multiple-if-conditions#comment-1244066</link>
    <description> &lt;p&gt;&lt;div class=&quot;quote-msg&quot;&gt;&lt;div class=&quot;quote-author&quot;&gt;&lt;em&gt;aharown07&lt;/em&gt; wrote:&lt;/div&gt;Conditional logic still confuses me a bit.&lt;/div&gt;It can sometimes be tricky depending on what you are trying to do, and if you use equals or does not equal, and or etc. The combinations can get tricky.&lt;br /&gt;
Trial and error and testing with the code you&#039;re working with to see what it outputs is the best way.&lt;/p&gt;
&lt;p&gt;You can simplify your code. If you think:&lt;br /&gt;
&quot;&amp;amp;&amp;amp;&quot; is more like &quot;BOTH&quot; (or &quot;ALL&quot; if more than two conditions)&lt;/p&gt;
&lt;p&gt;With this:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype1&#039; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype2&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;):&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Simply means for IF to be TRUE, &lt;strong&gt;BOTH&lt;/strong&gt; conditions have to &lt;strong&gt;NOT EQUAL&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If your $type variable was set to either &quot;contenttype1&quot; or &quot;contenttype2&quot;, then it would return FALSE, as one of the conditions WOULD be equal&lt;br /&gt;
I.E. &lt;strong&gt;BOTH&lt;/strong&gt; are &quot;not&quot; &lt;strong&gt;NOT EQUAL&lt;/strong&gt; because one if them IS EQUAL&lt;/p&gt;
&lt;p&gt;If however your $type variable was set to &quot;contenttype5&quot;, then it would return TRUE, as &lt;strong&gt;BOTH&lt;/strong&gt; conditions are &lt;strong&gt;NOT EQUAL&lt;/strong&gt; to it&lt;/p&gt;
&lt;p&gt;You are looking for the var to NOT be &lt;strong&gt;BOTH&lt;/strong&gt; specific things.&lt;/p&gt;
&lt;p&gt;------&lt;br /&gt;
Whereas using &quot;OR&quot;&lt;br /&gt;
&quot;OR&quot; is is more like &quot;EITHER&quot; (or &quot;ANY&quot; if more than two conditions)&lt;/p&gt;
&lt;p&gt;The first code you posted:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype1&#039; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;OR &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype2&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;):&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Simply means for IF to be TRUE, &lt;strong&gt;EITHER&lt;/strong&gt; conditions has to &lt;strong&gt;NOT EQUAL&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This actually would always return TRUE, as $type cannot be both contenttype1 and contenttype2&lt;br /&gt;
EG&lt;br /&gt;
If $type is set to &quot;contenttype1&quot; then it != &quot;contenttype2&quot; - TRUE&lt;br /&gt;
If $type is set to &quot;contenttype2&quot; then it != &quot;contenttype1&quot; - TRUE&lt;/p&gt;
&lt;p&gt;With OR you usually use either two different variables to check (or more) or you don&#039;t use &quot;does not equal&quot;.&lt;br /&gt;
EG&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype1&#039; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;OR &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype2&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;):&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
Simply means for IF to be TRUE, &lt;strong&gt;EITHER&lt;/strong&gt; one of the conditions has to be &lt;strong&gt;EQUAL&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If your $type variable was set to either &quot;contenttype1&quot; or &quot;contenttype2&quot;, then it would return TRUE, as one of the conditions WOULD be equal&lt;br /&gt;
If however your $type variable was set to &quot;contenttype5&quot;, then it would return FALSE, as &lt;strong&gt;NEITHER&lt;/strong&gt; conditions are &lt;strong&gt;EQUAL&lt;/strong&gt; to it&lt;/p&gt;
&lt;p&gt;You are looking for the var to be &lt;strong&gt;EITHER&lt;/strong&gt; of two specific things.&lt;/p&gt;
&lt;p&gt;---------&lt;br /&gt;
Again, it can get tricky.&lt;br /&gt;
If you are doing something that you cannot get your head around, try outputting something simple.&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;test text&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype1&#039; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype2&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;was true&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;}else{&lt;br /&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;was false&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Thu, 06 Aug 2009 11:42:08 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1244066 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Won&#039;t that result in the</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/little-php-help-multiple-if-conditions#comment-1244059</link>
    <description> &lt;p&gt;Won&#039;t that result in the condition having to satisfy both since it&#039;s an AND statement?&lt;/p&gt;
 </description>
     <pubDate>Thu, 06 Aug 2009 07:44:24 +0000</pubDate>
 <dc:creator>jamespvee</dc:creator>
 <guid isPermaLink="false">comment 1244059 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Many thanks! That makes</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/little-php-help-multiple-if-conditions#comment-1243759</link>
    <description> &lt;p&gt;Many thanks! That makes sense to me now.&lt;/p&gt;
 </description>
     <pubDate>Tue, 28 Jul 2009 10:52:02 +0000</pubDate>
 <dc:creator>aharown07</dc:creator>
 <guid isPermaLink="false">comment 1243759 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Code should be:
&lt;?php if</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/little-php-help-multiple-if-conditions#comment-1243730</link>
    <description> &lt;p&gt;Code should be:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype1&#039; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;contenttype2&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;): &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 27 Jul 2009 22:57:56 +0000</pubDate>
 <dc:creator>pr0gr4mm3r</dc:creator>
 <guid isPermaLink="false">comment 1243730 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
