Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constants and CodeIgniter

Tags:

codeigniter

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; ?>"> 
like image 421
sehummel Avatar asked Nov 30 '22 04:11

sehummel


1 Answers

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;
like image 58
bhu1st Avatar answered Dec 04 '22 08:12

bhu1st