adam.timberlake wrote:

> Im reading this post and i donnot understand how i should write my code:
> Does it mean that i am to not write else statements in my ifs? or is it
> just saying it is something i should avoid to rite better code?
> please help me...

I happen to not agree completely with the post, because it seems to 
propose the use of things like "continue", "break" and "return" within 
control structures (the latter as opposed to at the end of a function, 
exclusively). Very bad practice in my opinion. Think of everything that 
has ever been said of "goto", it's just as bad for structured programming.

(however the use of "break" in "switch .. case" statements is an 
unfortunate necessity in PHP)

Not that I am diagramming much nowadays, but I still try to write code 
such that it could fit into a Nassi-Shneiderman diagram (NSD):


If you have never learnt to draw these then you probably should. It can 
be fun to do and they are very helpful for planning ahead and writing 
uncluttered code that can be easily debugged. And you will know you are 
nesting too deep when the diagram doesn't fit on the piece of paper you 
started on :)

To more directly answer your question I would say that if there is a 
*logical* requirement to use "else" after "if" then yes, you should use 
it and certainly not try to avoid it. There is absolutely nothing wrong 
with "else".

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to