I started with CSS so I always used brackets this way:
#content {
selector: value;
}
While using CodeIgniter I noticed that each file have the brackets like this:
function something here()
{
$this->$item('item');
$data['rows'] = $this->data_model->getAll();
$this->load->view('home', $data);
}
Is the second example better for readability or copying or pasting?
That actually looks a bit wrong for CodeIgniter; according to the Style Guide, they use Allman style. See this article on Wikipedia for some background on indentation styles. [NB: indentation now fixed in question].
Really, though, it's just a matter of religion (note that Wikipedia's Indent Style article is currently linked to from its Wars of Religion article!)
The best thing to do is to be consistent.
So, for your own project, use whatever you feel is the most readable/usable. But if you wanted to contribute code to CodeIgniter, you'd use the Allman style, and if you're writing a project that just uses CodeIgniter, it might be easier to follow their style simply to stop your brain from having to swap between two styles while you're simultaneously digging through their code and writing yours.
No difference at all, you can use this style just if it's more understandable for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With