Constants and CodeIgniter

Can I use constants in CodeIgniter for things like repeating text (like meta tags and meta descriptions) throughout the site? Sort of:

define('METADESCRIPTION', 'This is my site'); 

and then echo METADESCRIPTION in meta tags?

 <meta name="description" content="<?php echo METADESCRIPTION; ?>"> 
+4
source share
1 answer

Yes.

For access throughout the application, you can define constants in the config.php file or even in the index.php files.

config.php or in index.php

 define('METADESCRIPTION', 'This is my site'); 

on your controllers or views.

Assing

 $myVar = METADESCRIPTION; 

or access

 echo METADESCRIPTION; 
+18
source

Source: https://habr.com/ru/post/1342183/


All Articles