Welcome Guest, Not a member yet? Register   Sign In
Prefixing private variables with underscores
#1

[eluser]JonathanYC[/eluser]
Hello!
In the CodeIgniter Style Guide, it is reccommended that I prefix private variables with underscores.
However, does that mean I should prefix these variables with underscores:

1.
foreach ($tags as $tag)
Should that be:
foreach ($_tags as $_tag)
After of course I rename $tags to $_tags

2.
$tag_query = $this->db->select('id') ...
Should that be:
$_tag_query

This all seems very extraneous and does not appear to help readability.

Could I have your guys' opinion on it?

Thanks!
#2

[eluser]mddd[/eluser]
It's entirely up to you. I don't use that style in my own controllers and models.
I think it's different in code that is going to be reused or shared. I would consider it in a library, because if you are reusing it a year from now, it's easier to understand. Or if you are going to share code (like in CI itself) then it is important.
In your own code, do what feels best for you!




Theme © iAndrew 2016 - Forum software by © MyBB