Setting constant values


show more Setting constant values 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 ...

Setting constant values

There's a strong possibility that you're already familiar with constants. They are common place in procedural code. As a natural extension, it's possible to add a constant to a class, which can be good for code organization. A class constant is like a property with a value that never changes. Constants are useful for defining things like error codes, data structure names, and values that have no need to change at runtime, if ever. By associating a constant with a class, a developer can add context rather than having to resort to long, complicated names. While constants use the same PHP label naming convention, best practice dictates that constant names are all in capital letters separated by underscores. Constants can only contain simple values, so strings, booleans and integers will work, but an array will not. To define a constant within a class, start with the keyword "const," followed by the name with no dollar sign ($), an assignment operator, a...

Setting constant values
Video duration: 2m 47s 1h 57m Intermediate Updated Apr 10, 2013

Viewers:

Setting constant values 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 ...