[thelist] PHP if exit Q

Steve Lewis nepolon at worlddomination.net
Tue Aug 26 17:24:24 CDT 2003


jsWalter wrote:

>    Fatal error: Cannot break/continue 1 level in 
>  
>
yup, break/continue is for loop execution, not for conditional execution.

you need something like the following?
<code>
if (typeOf(cat) == 'mammal')
{
    if (typeOf(cat) == 'feline')
    {
       // Section A
        echo '<h1>meow</h1>';
     }
     else
    {
       // Section B we jump out of here
     }
     // Section C and not execute this.
}
else
{
  // Section D we do not want to land here
}

// Section E we want to land here

<code>
Because that is what I am hearing.

Answer:  move Section C after Section A inside the 2nd "if" block.  It 
sounds to me like you only want to execute Section C if Both conditions 
are true.

Please specify some code if this is not the case to help us see your 
logic better. :)

--Steve

<tip author="Steve Lewis" type="coding conditional logic with Karnaugh 
Maps">
Learn to use Karnaugh Maps (aka K-maps) to help simplify ugly 
conditional logic.**  When you learn how to use them, they can make 
quick work of tricky logic, and help you enumerate all the cases you 
need to test, never leave an unconsidered case in complex binary 
(true/false) evaluations. 

Then using the "else if" clause, if you have one available, you can 
potentially simplify the logic of a K-map where there are many nested 
else clauses.

one good introduction to Karnaugh Maps is available at 
http://www.maxmon.com/kmaps1.htm
</tip>



More information about the thelist mailing list