Defining class properties


show more Defining class properties provides you with in-depth training on Developer. Taught by Jon Peck as part of the Object-Oriented Programming with PHP show less
please wait ...

Defining class properties

As you may recall, a class property is a structure for storing values. A class can have any number of properties associated with it. Each property is defined with a visibility keyword: public, protected, or private. If you leave out the keyword, you're going to get a parse error. I'll explore visibility scope in greater detail in a later video. For the time being, let's just stick with public properties that have no access restrictions. Properties are declared kind of like regular variables, including the naming conventions for PHP labels. Same as class naming, property names must either start with a letter or underscore, then be followed by any number of letters, numbers, and underscores.

When naming a property, a best practice is to use lowerCamel naming, meaning the first letter of the name needs to be lowercase, and then the first letter of any remaining words should be capitalized. Avoid naming a public property with an underscore at the beginning. Depending on the coding ...

Defining class properties
Video duration: 3m 26s 1h 57m Intermediate Updated Apr 10, 2013

Viewers:

Defining class properties provides you with in-depth training on Developer. Taught by Jon Peck as part of the Object-Oriented Programming with PHP

Subject:
Developer
Software:
PHP
Author:
please wait ...