CyberShot Posted April 8, 2011 Share Posted April 8, 2011 I am working with wordpress and I see a lot of "if" statements done like this if(condition): do something endif; I have always done it like so if(condition) { do something } what is the difference? does the first method have any advantages over the second method? Quote Link to comment https://forums.phpfreaks.com/topic/233117-what-is-the-difference/ Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 It's alternative syntax for control structures. Quote Link to comment https://forums.phpfreaks.com/topic/233117-what-is-the-difference/#findComment-1198897 Share on other sites More sharing options...
salathe Posted April 8, 2011 Share Posted April 8, 2011 what is the difference? does the first method have any advantages over the second method? Some folks prefer the "alternative" syntax when mixing HTML or other blocks of output with basic PHP, especially when mixing different types of control blocks (loops, conditions, etc.) where the closing statement (endwhile, endif, etc.) is much clearer than a random curly brace . Outside of that, it's not very common at all to it. Quote Link to comment https://forums.phpfreaks.com/topic/233117-what-is-the-difference/#findComment-1198963 Share on other sites More sharing options...
CyberShot Posted April 8, 2011 Author Share Posted April 8, 2011 I could see using the alternative when mixing html. I guess it would be easier to spot. That sounds like a good reason to make an alternative Quote Link to comment https://forums.phpfreaks.com/topic/233117-what-is-the-difference/#findComment-1198966 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.