duanqian8867
2014-05-14 22:30 阅读 29
已采纳

在Dreamweaver中创建“模式”

I'm a Dreamweaver and php noobie (I'm a C++ developer), I'd like to know if there's a way to define different "modes" (e.g. Debug, Release, etc.)? For example, I'd like to be able to have a Debug and Release mode that would affect my database connection and other variables, I'd like to be able to use this in code by doing something like:

if($DEBUGGING)
{ // set connection to debug connection string
}
else
{ // set connection to release connection string
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doujia9833 doujia9833 2014-05-14 22:44

    http://ca1.php.net/define

    header.php

    define('DEV_ENV', 'staging');
    

    other files

    if( !defined('DEV_ENV') ) { die('error message here'); }
    
    switch(DEV_ENV) {
      case 'production':
        $conn_string = "foo";
        break;
      case 'staging':
        $conn_string = "bar";
        break;
      case 'development':
        $conn_string = "baz";
        break;
      default:
        die('error message here');
    }
    
    点赞 评论 复制链接分享

相关推荐