不懂 PHP,看了半天,还是语法不明白,所以来咱 ruby 问问,希望有先行者指点一二。代码如下 这是个打开网站首页调用的代码
<?php
$SCRIPT_START_TIME = microtime(TRUE);
chdir(dirname(__FILE__));
require_once('./helpers/func_main.php');
require_once('./conf_system.php');
session_start();
//$httpsqs = new httpsqs_client("127.0.0.1", 1218, "q1w2e3r4t5y6", "utf-8");
$cache = new cache();
$db1 = new mysql($C->DB_HOST, $C->DB_USER, $C->DB_PASS, $C->DB_NAME);
if( ! $C->INSTALLED ) {
exit;
}
$network = new network();
$network->LOAD();
$hcadmin=new hcadmin();
$hcadmin->LOAD();
$user = new user();
$user->LOAD();
ob_start('ob_gzhandler', 6);
$page = new page();
$page->LOAD();
?>
其中
$db1 = new mysql($C->DB_HOST, $C->DB_USER, $C->DB_PASS, $C->DB_NAME);
这句应该是链接数据库了,参数明白代的意思。但这个$C ->DBHOST,是个什么表达方法?什么意思了?是有定义了一个全局的变量 C,然后赋值 DB-HOST,再作为参数? 在同目录下的 conf_main.php 文件发现如下
<?php
// Site Address Here:
//
$C->DOMAIN = $_SERVER['HTTP_HOST'];
$C->SITE_URL = 'http://' . $_SERVER['HTTP_HOST'] .'/';
if( substr($_SERVER['HTTP_HOST'], 0, 2) == 'm.' || substr($_SERVER['HTTP_HOST'], 0, 4) == 'wap.') {
$C->DOMAIN = $_SERVER['HTTP_HOST'];
$C->SITE_URL = 'http://' . $_SERVER['HTTP_HOST'] . "/";
}
//
//echo $C->DOMAIN;exit;
// Random identifier for this installation on this server
//
$C->RNDKEY = '502e6';
//
// MySQL SETTINGS
//
//$C->DB_HOST = '101.226.179.210 ';
//$C->DB_USER = 'sq_s520426db0';
//$C->DB_PASS = 'tiapq666';
//$C->DB_NAME = 'sq_s520426db0';
$C->DB_HOST = 'localhost';
$C->DB_USER = 's520426db0';
$C->DB_PASS = 'tiapq666';
$C->DB_NAME = 's520426db0';
$C->DB_MYEXT = 'mysql'; // 'mysqli' or 'mysql'
//
// CACHE SETTINGS
//
$C->CACHE_MECHANISM = 'filesystem'; // 'apc' or 'memcached' or 'mysqlheap' or 'filesystem'
$C->CACHE_EXPIRE = 3600;
$C->CACHE_KEYS_PREFIX = '502e6';
// If 'memcached':
$C->CACHE_MEMCACHE_HOST = '192.168.0.2';
$C->CACHE_MEMCACHE_PORT = '11200';
// If 'filesystem':
$C->CACHE_FILESYSTEM_PATH = $C->INCPATH.'cache/';
//
// IMAGE MANIPULATION SETTINGS
//
$C->IMAGE_MANIPULATION = 'gd'; // 'imagemagick_cli' or 'gd'
// if 'imagemagick_cli' - /path/to/convert
$C->IM_CONVERT = 'convert';
//
// DEFAULT LANGUAGE
//
$C->LANGUAGE = 'en';
//
// USERS ACCOUNTS SETTINGS
//
// if urls are user.site.com or site.com/user
// this setting is still beta and it is not working properly
$C->USERS_ARE_SUBDOMAINS = FALSE;
//
// RPC PING SETTINGS
//
$C->RPC_PINGS_ON = TRUE;
$C->RPC_PINGS_SERVERS = array('http://rpc.pingomatic.com');
//
// TWITTER & FACEBOOK CONNECT SETTINGS
//
// To activate Facebook Connect, check out the README.txt file
$C->FACEBOOK_API_KEY = '';
// To activate Twitter OAuth login, check out the README.txt file
$C->TWITTER_CONSUMER_KEY = '';
$C->TWITTER_CONSUMER_SECRET = '';
// Bit.ly Integration - used for sharing posts to twitter
$C->BITLY_LOGIN = 'blogtronixmicro';
$C->BITLY_API_KEY = 'R_ffd756f66a4f5082e37989f1bc3301a6';
// For inviting Yahoo contacts. Check out the README.txt file
$C->YAHOO_CONSUMER_KEY = '';
$C->YAHOO_CONSUMER_SECRET = '';
//
// FOOTER "Powered by Blogtronix" BACKLINK
//
// The License requires you to keep this backlink. To remove it, visit this page
// and follow the instructions: http://sharetronix.com/sharetronix/linkremoval
// Otherwise you are not allowed to modify this variable or remove the link.
$C->FOOTER_REMOVE_BACKLINK = FALSE;
//
// IF YOUR SERVER SUPPORTS CRONJOBS, READ THE FILE ./system/cronjobs/readme.txt
//
$C->CRONJOB_IS_INSTALLED = FALSE;
//
// DO NOT REMOVE THIS
//
$C->INSTALLED = TRUE;
$C->VERSION = '1.5.4';
$C->DEBUG_USERS = array();
//
?>
似乎这应该是配置文件,但还是不明白$C->DB_HOST 的写法是要做什么,我猜测是可以全局引用$C?