开发者

Constants and CodeIgniter

开发者 https://www.devze.com 2023-02-14 12:25 出处:网络
Can constants in CodeIgniter be used for things like recurring text (say metatags and meta-descriptions) throughout the site?Something like:

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消