开发者

Why does CodeIgniter force classes to have their first letter capitalised?

开发者 https://www.devze.com 2023-03-06 09:26 出处:网络
As per the creating libraries document开发者_运维技巧ation: File names must be capitalized. For example:Myclass.php

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号