Class Constants - PHP - P45

Опубликовано: 20 Февраль 2026
на канале: Dino Cajic
261
7

Class constants are similar to regular constants with the exception that they live inside the class. Class Constants cannot be changed, hence the name constant. They're declared using the const keyword and are allocated in memory once per class and not each time that you instantiate the object. To access the class constant, you need to use the class name and the scope resolution operator (double colon).

Read the full article on my website
https://www.dinocajic.com/php-class-c...

Code for this tutorial
https://github.com/dinocajic/php-7-yo...

Full Code
https://github.com/dinocajic/php-7-yo...

PHP Playlist
   • PHP Tutorial  

--
Dino Cajic
Author and Head of IT

Homepage: https://www.dinocajic.com
GitHub: https://github.com/dinocajic
Medium:   / dinocajic  
Instagram:   / think.dino  
LinkedIn:   / dinocajic  
Twitter:   / dino_cajic  

My Books
An Illustrative Introduction to Algorithms
https://www.amazon.com/dp/1686863268

Laravel Excel: Using Laravel to Import Data
https://amzn.to/4925ylw

Code Along With Me - PHP: From Basic to Advanced PHP Techniques
https://amzn.to/3M6tlGN