Answer the question
In order to leave comments, you need to log in
What to choose: $someVar or $some_var?
What to choose: $someVar or $some_var?
Answer the question
In order to leave comments, you need to log in
Throw a coin.
This topic will give no more information, but there will be a lot of flooding.
We have adopted $someVar, but I rarely see names like $some_var, except in scripts.
code-cruising.net/underscore-vs-camelcase-naming-convention
$someVar is a class parameter.
$some_var is an internal variable inside the method.
Depends on what you're working with. For example, in ZendFramework it is customary to use camelCaps [ proof ].
But by and large, it doesn’t matter, the main thing is that you yourself always adhere to the rule adopted by yourself.
for variables I use camelCaps… here they write that for functions it is better to use the underscore method, but I don’t like it… I also use camelCase for functions.
Practice shows that the third option, $p $a and of course $c, is the most common.
Mother by the leg!
More familiar camelCaps.
And slightly, but the length of the line is reduced.
Start using the Zend coding standard (http://zend-framework.ru/pamyatka-po-standartam-kodirovaniya/) and many questions will disappear.
In Javascript, it’s generally bad manners to write under_score, only camelCase. At the same time, in ruby, as I understand it, it is necessary to write only with underscores. So really - look at the environment.
I prefer camelcase
I use camelCaps for variables, properties, methods and functions. In addition to a shorter length, they allow you to visually separate your functions from the standard ones (not always, but often).
In Drupal, for example ( coding standard ), it is accepted as follows:
$some_var
class SomeClass {
}
$object->someMethod()
$object->someProperty
in php, it is customary to use the PEAR style, now the Zend Framework, these are the two most powerful sets of libraries that can be easily integrated into your project. It will be very frustrating when the project ends up with a mixture of styles. it's better to just use it without hesitation, although there are a lot of pros and cons.
If you want to deal with the issue in more detail, then I advise you to read McConnell: Perfect code
This will prove once again that there is no ideal approach.
The answer is really obvious, and depends on two things:
1 - What libraries do you work with? Perhaps you should use their style?
2 - Which option do you personally like more? The main thing is to choose one and always stick to it.
I use camelCase, I just saw such examples more often and I intuitively like it more.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question