常量和CodeIgniter [英] Constants and CodeIgniter
本文介绍了常量和CodeIgniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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');
然后将METADESCRIPTION回显到meta标签中?
and then echo METADESCRIPTION into the meta tags?
<meta name="description" content="<?php echo METADESCRIPTION; ?>">
推荐答案
是.
要访问整个应用程序,您可以在config.php甚至index.php文件中定义常量.
For access throughout the app you can define constants in config.php or even in index.php files.
config.php或index.php
config.php or in index.php
define('METADESCRIPTION', 'This is my site');
在您的控制器或视图上.
on your controllers or views.
确定
$myVar = METADESCRIPTION;
或访问
echo METADESCRIPTION;
这篇关于常量和CodeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文