Can constants in CodeIgniter be used for things like recurring text (say metatags and meta-descriptions) throughout the site? Something like:
define('METADESCRIPTION', 'This is my site');
and then echo METADESCRIPTION into the meta tags?
<meta name="description" content="<?php echo METADESCRIPTION; ?>">
Yes.
For access throughout the app you can define constants in config.php or even in 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;
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