Why does CodeIgniter force classes to have their first letter capitalised?
As per the creating libraries document开发者_运维技巧ation:
File names must be capitalized. For example: Myclass.php
Class declarations must be capitalized. For example: class Myclass
Why is this? Once it's loaded as a property (e.g. $this->myclass->do_something()
) it's lowercased anyway.
that "myclass" thingy ($this->myclass
) is an instance of the class, not a class.
Instances / objects are lowercase, but the class is uppercase. Calling a static function would go like Myclass::do_something_statically()
(notice the uppercase).
So the lowercase thing is something else, and making the class upcase will let you see the difference :)
Maybe for the same reason German capitalizes nouns.
It make it more easy for human readers to 'parse' the text.
精彩评论