Variable naming convention

Hello everyone,

I have been working with PHP for the last years and I am always trying to code better and also make it so other people can see read my work and be able to easily understand what each part of it means.

For the last few days I been reading about naming conventions but there is one I have not been able to found reference for but I am guessing this is used for the private variables so I just want to confirm if anyone knows if that is how it normally is used.

basically when you have something like

$this->_variable

Is that underscore usually used for private variables or it has just happen that I found it being used that way?

Your guess is correct. Though, this convention isn’t used much anymore. It’s a relic from the PHP4 days when everything was public. Today we can make variables truly private or protected, so the underscore is redundant now.

thank you Jeff!

Based on what you said, would you use it just considering that someone else may need to edit your code and that would make it easier for them to read?