|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Question About Curly brackets { }
I'm new to nested if statements and I'm loosing track of those curlies. Is this the right way of writing these statements?
PHP Code:
|
|
#2
|
||||
|
||||
|
Just lay out your code properly and you wont have problems
PHP Code:
Now we can see which bracket lines up with the other. And you have the right amount. |
|
#3
|
||||
|
||||
|
PHP Code:
|
|
#4
|
||||
|
||||
|
Third time in a row when a.koepke beat me to it!!
![]() |
|
#5
|
||||
|
||||
|
What can you expect, he is good.
![]() |
|
#6
|
||||
|
||||
|
lol. he types at an amazing 400 words a minute, seriously....
|
|
#7
|
||||
|
||||
|
lol. Refer to thread "this is war" from the archive. That should give you about 90 posts worth of info on the topic.
|
|
#8
|
|||
|
|||
|
I want to say thanks to everyone that responded.
great examples. Monkey's response left no room for doubt! Thanks. After lining up the curly brackets under the "if" and "else" I was able to debug my app in five minutes!. |
|
#9
|
||||
|
||||
|
yeah, it really pays in the long run to block your code and keep proper bracket alignment.
|
|
#10
|
||||
|
||||
|
Just an interesting piece of trivia: If you wrote Sam777's code in Mumps, it'd be:
Code:
i me=monkie w "I am a monkie!" e d . i me=monkie w "I am a monkie!" . e d .. i me=monkie w "I am a monkie!" .. e d ... i me=monkie w "I am a monkie!" ... e d .... w "I think you get the idea!!!" Mumps is a nice language sometimes. Just count the periods to see what loop you're in. ("e d"="Else Do") |
|
#11
|
||||
|
||||
|
well thats just wierd...
|
|
#12
|
||||
|
||||
|
Quote:
My thoughts exactly.... no wonder I havent heard of that language. |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Question About Curly brackets { } |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|