Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I stopped at the if/elseif/else part... there're that many variations how you can write the same thing in PHP:
- if ( $age > 10 ) {
- echo "foo";
- } elseif ( 10 === $age ) { # strict comparison
- echo "bar";
- } else {
- echo "baz";
- }
- // In above you can put the brackets on different lines. You can as well avoid them completely. Or you can do other stuff:
- $age > 10
- ? print "bar"
- : print "foo";
- // Or you can go nuts:
- $result = "foo";
- $age < 10 AND $result = "bar";
- echo $result;
- // and so on. This is just the tip of the iceberg. While Python is nice, I personally prefer PHP for allowing full type safety like you // know it from Java or C# while still having the ability to write with a very custom style.
- // Another example of if:
- if ( $age > 10 ) :
- print "foo";
- elseif ( 10 === $age ) :
- print "baz";
- else :
- print "bar";
- endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement