dongping4273 2014-09-10 11:25
浏览 42

如何在codeigniter中声明全局变量?

This is my path.$t is my variable which holds the path.one time change want to reflect everywhere ??

$t="/var/www/upload/videos_comm/";
  • 写回答

2条回答 默认 最新

  • doumen1883 2014-09-10 11:28
    关注

    You can use the file in /application/config called constants.php. You can use that file to declare your global variable.

    Or you can use define as Pankucins suggested like this:

    <?php
    define("CONSTANT", "Hello world.");
    echo CONSTANT; // outputs "Hello world."
    echo Constant; // outputs "Constant" and issues a notice.
    
    define("GREETING", "Hello you.", true);
    echo GREETING; // outputs "Hello you."
    echo Greeting; // outputs "Hello you."
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试