diff --git a/guide/english/php/constants/index.md b/guide/english/php/constants/index.md index e580e1364b..d49eab7deb 100644 --- a/guide/english/php/constants/index.md +++ b/guide/english/php/constants/index.md @@ -18,6 +18,21 @@ echo freeCodeCamp; Learn to code and help nonprofits ``` +Also, when you are creating classes, you can declare your own constants. + +```php +class Human { + const TYPE_MALE = 'm'; + const TYPE_FEMALE = 'f'; + const TYPE_UNKNOWN = 'u'; // When user didn't select his gender + + ............. +} +``` + +**Note:** If you want to use those constants inside the `Human` class, you can refer them as `self::CONSTANT_NAME`. If you want to use them outside the class, you need to refer them as `Human::CONSTANT_NAME`. + #### More Information: * php.net constants manual * php.net define() manual +* Create your first PHP class