/** * init * 开始生产框架结构 * * @Access public * @Return void */ public static function init() { self::$const = Myconst(); self::$const['Classes'] = './Public/Classes/'; self::$const['Controll'] = './' . rtrim(ltrim(APP_PATH, './'), '/') . '/Controll/'; self::$const['Model'] = './' . rtrim(ltrim(APP_PATH, './'), '/') . '/Model/'; self::$const['ActionModel'] = './' . rtrim(ltrim(APP_PATH, './'), '/') . '/Model/ActionModel/'; self::$const['FactoryModel'] = './' . rtrim(ltrim(APP_PATH, './'), '/') . '/Model/FactoryModel/'; self::$const['index'] = './home/View/' . trim(TEMPLATE_STYLE, '/') . '/index/'; self::$const['Mycss'] = MYPUBLIC . 'css/'; self::$const['Myimages'] = MYPUBLIC . 'images/'; self::$const['Myjs'] = MYPUBLIC . 'js/'; self::makeDirs(self::$const); //调用创建目录 self::createControll(); }
<?php require "tests.php"; require "pointer_reference.php"; $s = pointer_reference::get(); check::equal($s->value, 10, "pointer_reference::get() failed"); $ss = new Struct(20); pointer_reference::set($ss); $i = Struct::instance(); check::equal($i->value, 20, "pointer_reference::set() failed"); check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed"); check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed"); check::done();
public function writePacket(Struct &$packet) { if ($this->socketType == SOCKTYPE_UDP) { return $this->writeUDP($packet->pack()); } else { return $this->writeTCP($packet->pack()); } }
public function unpack($rawPacket) { parent::unpack($rawPacket); for ($i = 0; $i < $this->NumHosts; $i++) { $this->Info[$i] = new HInfo(substr($rawPacket, 4 + $i * 40, 40)); } return $this; }
public function pack() { if (strLen($this->Text) > 239) { $this->Text = subStr($this->Msg, 0, 239); } return parent::pack(); }
<?php require_once '../phuby.php'; // $customer = new Struct('first_name', 'last_name'); $customer = Struct::new_instance('first_name', 'last_name'); $sean = $customer->instance('Sean', 'Huber'); echo $sean->first_name . "\n"; echo $sean->last_name . "\n"; echo $sean->invalid . "\n"; // print_r($sean);
} } else { Debug::addmsg('<span style="color:red;">[未使用Memcache]</span>'); } if (IS_SESSION_TO_MEMCACHE && MEMCACHE) { SessionToMem::start(MyMemcache::getMemcache()); Debug::addmsg('开启Session==>Memcache'); } else { session_start(); } Debug::addmsg('SessionID: ' . session_id()); if (empty($_SESSION['configMtime'])) { $_SESSION['configMtime'] = filemtime('./Public/Config.inc.php'); } if (filemtime('./Public/Config.inc.php') > $_SESSION['configMtime']) { Struct::init(); //当修改配置文件,同样执行一次框架结构类 //自动根据数据库驱动切换继承关系 $_SESSION['configMtime'] = filemtime('./Public/Config.inc.php'); $String = file_get_contents(RELUC_DIR . 'Kernel/Model.class.php'); $replaceMent = 'extends Base' . ucfirst(strtolower(DB_DRIVER)) . "\n"; $String = preg_replace('/extends\\s+\\w+\\s+/', $replaceMent, $String); file_put_contents(RELUC_DIR . 'Kernel/Model.class.php', $String); } $_GET['m'] = !isset($_GET['m']) ? 'index' : strtolower($_GET['m']); $_GET['a'] = !isset($_GET['a']) ? 'index' : strtolower($_GET['a']); if (array_key_exists('PATH_INFO', $_SERVER)) { $pathinfo = trim($_SERVER['PATH_INFO'], '/'); $PATHINFO = explode('/', $pathinfo); $_GET['m'] = empty($PATHINFO[0]) ? 'index' : strtolower($PATHINFO[0]); $_GET['a'] = empty($PATHINFO[1]) ? 'index' : $PATHINFO[1];
function select($block) { return $this->to_a()->select($block); } function to_a() { $result = new Arr(); foreach ($this->members as $member) { $result[] = $this->{$member}; } return $result; } function to_h() { $result = new Hash(); foreach ($this->members as $member) { $result[$member] = $this->{$member}; } return $result; } function values_at($keys) { $keys = func_get_args(); return $this->to_a()->call('values_at', $keys); } } Struct::extend('StructMethods'); Struct::alias_method('length', 'count'); Struct::alias_method('size', 'count'); Struct::alias_method('values', 'to_a');