justsomeguy Posted July 7, 2006 Share Posted July 7, 2006 I found that there is alternate syntax for a lot of different control statements. All of these examples work, they are taken from Programming PHP: if ($user_validated): echo "Welcome!";else: echo "Access forbidden!";endif;switch ($uname): case 'ktatroe': //do something break; case 'rasmus': //do something break; case 'petermac': //do something break;endswitch;while ($i <= 10): $total += $i; $i++;endwhile;for ($i = 1; $i <= 10; $i++): $total += $i;endfor;foreach ($array as $key => $value): // ...endforeach; Just something I didn't realize, I don't think I've ever seen this used in an example. Link to comment Share on other sites More sharing options...
scott100 Posted July 7, 2006 Share Posted July 7, 2006 Just something I didn't realize, I don't think I've ever seen this used in an example.The non use of curly brakets I've never seen that either, it's like asp'ish Link to comment Share on other sites More sharing options...
justsomeguy Posted July 7, 2006 Author Share Posted July 7, 2006 It's like VB, you can also use Javascript to write ASP. Link to comment Share on other sites More sharing options...
scott100 Posted July 7, 2006 Share Posted July 7, 2006 It's like VB, you can also use Javascript to write ASP.<{POST_SNAPBACK}> That's true, i stick to vbscript with asp though Hasn't vb been replaced by .net?I prefer the use of curly brakets though, i find it easier to visualise where structures begin/end. Maybe it's just the order i learnd languages though, others may find curly brackets weird. Link to comment Share on other sites More sharing options...
Sniffy Posted July 7, 2006 Share Posted July 7, 2006 And alternate sythax instead of braces?I'm surprised. Oh well, I'm sticking to the original one for now, don't want to confuse myself. Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted August 2, 2006 Share Posted August 2, 2006 Isn't that the old way? I always believed that's how php did it when it was first made, then they changed to the new way (I don't know for a fact, just in my experence) Link to comment Share on other sites More sharing options...
justsomeguy Posted August 2, 2006 Author Share Posted August 2, 2006 I don't know if there is an old or a new, maybe when the Zend engine first came out they changed the syntax, but it is definately useful for this type of thing: <?php if ($something): ?>.........<?php else: ?>.........<?php endif; ?> That just looks a little cleaner then using brackets. But I haven't seen much syntax for php versions 1 or 2, they changed a lot of things for version 3 when they added Zend. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now