Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Is this type of coding frowned uppon in the php community?
  • I'm not sure why I don't see many people coding this way.
    foreach ($query as $variable):
            // Code here
    endforeach;
    

    as opposed to
    foreach ($query as $variable) {
      // Code here
    }
    

    same goes for IF statements.
  • It's about preference, I prefer to use {} as well. The coding guidelines for code for the core require it. Only reason for me to use foreach:...endforeach; is in templates where {} don't make sence as there's a lot non-PHP in between.
  • I always use { } in anything other than a view, and in views I generally have a preference for if foo(...): if I then I close php ?> and use <?=$foo?> instead of writing it with echo. Just looks neater and is easier to read!
  • I typically use foreach:/endforeach; (and ifs) in template/view files and {}'s in everything else.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion