I am using codeigniter for a project. I have a custom library in which there are constants in which I will use in my custom functions in the library. How do I declare such constants?
If you are going to use that constants only in your library, you must declare it inside of your class:
<?php
class my_class {
const MY_CONSTANT = 10;
And then call it with:
self::MY_CONSTANT
If you need that your constants are available in the rest of the application, you must declare it in your application/config/constants.php file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With