Matt
Matt

Reputation: 9433

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

As per the creating libraries documentation:

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.

Upvotes: 2

Views: 897

Answers (2)

pavium
pavium

Reputation: 15118

Maybe for the same reason German capitalizes nouns.

It make it more easy for human readers to 'parse' the text.

Upvotes: 0

Nanne
Nanne

Reputation: 64399

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 :)

Upvotes: 2

Related Questions