本文整理汇总了PHP中c函数的典型用法代码示例。如果您正苦于以下问题:PHP c函数的具体用法?PHP c怎么用?PHP c使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了c函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exec
public function exec($key)
{
//匿名函数
if ($this->route[$key]['callback'] instanceof Closure) {
//反射分析闭包
$reflectionFunction = new \ReflectionFunction($this->route[$key]['callback']);
$gets = $this->route[$key]['get'];
$args = [];
foreach ($reflectionFunction->getParameters() as $k => $p) {
if (isset($gets[$p->name])) {
//如果GET变量中存在则将GET变量值赋予,也就是说GET优先级高
$args[$p->name] = $gets[$p->name];
} else {
//如果类型为类时分析类
if ($dependency = $p->getClass()) {
$args[$p->name] = App::build($dependency->name);
} else {
//普通参数时获取默认值
$args[$p->name] = App::resolveNonClass($p);
}
}
}
echo $reflectionFunction->invokeArgs($args);
} else {
//设置控制器与方法
$_GET[c('http.url_var')] = $this->route[$key]['callback'];
Controller::run($this->route[$key]['get']);
}
}
示例2: test_c
public function test_c()
{
$GLOBALS['config']['unittest'] = 'ing';
$this->assertEqual(c('unittest'), 'ing');
unset($GLOBALS['config']['unittest']);
$this->assertFalse(c('unittest'));
}
示例3: yudingcarlist
public function yudingcarlist($table, $rows)
{
$dt = $this->date;
$dtobj = c('date');
$db = m('careserve');
for ($i = 0; $i < 5; $i++) {
if ($i > 0) {
$dt = $dtobj->adddate($dt, 'd', 1);
}
foreach ($rows as $k => $rs) {
$carid = $rs['id'];
$arr = $db->getall("`carid`='{$carid}' and `status` in(0,1) and `startdt`<='{$dt} 23:59:59' and `enddt`>='{$dt} 00:00:00' order by `startdt` asc", '`usename`,`status`,`startdt`,`enddt`');
$str = '';
foreach ($arr as $k1 => $rs1) {
$stz = '<font color=blue>待审核</font>';
if ($rs1['status'] == 1) {
$stz = '<font color=green>已审核</font>';
}
$str .= '' . $rs1['usename'] . '使用(' . $stz . ')<br>' . substr($rs1['startdt'], 5, 11) . '→' . substr($rs1['enddt'], 5, 11) . '<br>';
}
$rows[$k]['dt' . $i . ''] = $str;
}
}
return array('rows' => $rows);
}
示例4: run
public static function run($routeArgs = [])
{
self::$routeArgs = $routeArgs;
//URL结构处理
$param = array_filter(explode('/', Request::get(c('http.url_var'))));
switch (count($param)) {
case 2:
array_unshift($param, c('http.default_module'));
break;
case 1:
array_unshift($param, c('http.default_controller'));
array_unshift($param, c('http.default_module'));
break;
case 0:
array_unshift($param, c('http.default_action'));
array_unshift($param, c('http.default_controller'));
array_unshift($param, c('http.default_module'));
break;
}
Request::set('get.' . c('http.url_var'), implode('/', $param));
$param[1] = preg_replace_callback('/_([a-z])/', function ($matches) {
return ucfirst($matches[1]);
}, $param[1]);
define('MODULE', $param[0]);
define('CONTROLLER', ucfirst($param[1]));
define('ACTION', $param[2]);
define('MODULE_PATH', ROOT_PATH . '/' . c('app.path') . '/' . MODULE);
define('VIEW_PATH', MODULE_PATH . '/' . 'view');
define('__VIEW__', __ROOT__ . '/' . c('app.path') . '/' . MODULE . '/view');
self::action();
}
示例5: buy
function buy($number, $uid = NULL)
{
$uid = format_uid($uid);
$money = intval(c('invite_price')) * $number;
$key = c('invite_use_gold') ? 'gold' : 'g';
$this->db->select($key)->from('app_ihome_user')->where('uid', $uid)->limit(1);
$now = lazy_get_var();
if ($now < $money) {
return false;
}
$sql = "UPDATE app_ihome_user SET {$key} = {$key} - {$money} WHERE uid = '{$uid}'";
lazy_run_sql($sql);
$data = array();
$data['u2_uid'] = $uid;
$data['u2_is_use'] = '0';
$data['u2_is_copied'] = '0';
$data['u2_date'] = date("Y-m-d");
while ($number > 0) {
do {
$icode = newpassword();
$check = $this->count_invite_code($icode);
} while ($check);
$data['u2_invite_code'] = $icode;
$this->db->insert('u2_invite', $data);
$number--;
}
return true;
}
示例6: bootstrap
public function bootstrap()
{
$this->constant();
//加载服务配置项
$servers = (require __DIR__ . '/service.php');
$config = (require ROOT_PATH . '/system/config/service.php');
$servers['providers'] = array_merge($config['providers'], $servers['providers']);
$servers['facades'] = array_merge($config['facades'], $servers['facades']);
$this->servers = $servers;
//自动加载系统服务
Loader::register([$this, 'autoload']);
//绑定核心服务提供者
$this->bindServiceProvider();
//添加初始实例
$this->instance('App', $this);
//设置外观类APP属性
ServiceFacade::setFacadeApplication($this);
//启动服务
$this->boot();
//定义错误/异常处理
Error::bootstrap();
//命令行模式
IS_CLI and die(Cli::bootstrap());
//导入类库别名
Loader::addMap(c('app.alias'));
//自动加载文件
Loader::autoloadFile();
//开启会话
Session::start();
//执行全局中间件
Middleware::globals();
//解析路由
Route::dispatch();
}
示例7: generate
public function generate($number, $value, $delimiter = ";")
{
if (!intval($number) && !intval($value)) {
return false;
}
for ($i = 0; $i < $number; $i++) {
//$code=rand(10000, 99999).rand(10000, 99999);
$code = sprintf("%010d", mt_rand());
$codeLength = $this->table->header[1][2];
while (strlen($code) < $codeLength) {
$code .= rand(0, 9);
}
$newId = $this->table->add(array('code' => $code, 'value' => $value, 'activated' => 0));
if (!$newId) {
$number++;
if ($number - 5 > $n) {
echo "Too much collisions.";
$this->response->success = false;
return;
}
} else {
$this->response->data[] = sprintf("%010d", $newId) . $delimiter . $code;
}
}
c("Successfully generated {$number} codes with value {$value}.");
$this->response->success = true;
}
示例8: get_data
function get_data($sql, $db = NULL)
{
if ($db == NULL) {
if (c('on_sae')) {
$db = db2();
} else {
$db = db();
}
}
$GLOBALS['LZ_LAST_SQL'] = $sql;
$data = array();
$i = 0;
$result = mysql_query($sql, $db);
if (mysql_errno() != 0) {
echo mysql_error() . ' ' . $sql;
}
while ($Array = mysql_fetch_array($result, MYSQL_ASSOC)) {
$data[$i++] = $Array;
}
if (mysql_errno() != 0) {
echo mysql_error() . ' ' . $sql;
}
mysql_free_result($result);
if (count($data) > 0) {
return $data;
} else {
return false;
}
}
示例9: xiangAjax
public function xiangAjax()
{
$mid = $this->get('mid');
$rs = m('work')->getone("`id`='{$mid}'");
$dtc = c('date');
$zt = $rs['state'];
$zts = $rs['state'];
if ($zt == '执行中') {
$zt = '<font color=#ff6600>' . $zt . '</font>';
}
if ($zt == '已完成') {
$zt = '<font color=green>' . $zt . '</font>';
}
if (!$this->isempt($rs['enddt']) && ($zts == '待执行' || $zts == '执行中')) {
$sjla = $dtc->diffstr($this->now, $rs['enddt'], 'd天H时i分', 1);
$sjsj = $dtc->datediff('i', $rs['enddt'], $this->now);
if ($sjsj > 0) {
$zt .= '<font color=red>超' . $sjla . '</font>';
}
}
$rs['zt'] = $zt;
$rs['logarr'] = m('workbg')->getall("mid='{$mid}' order by id desc", '`state`,`explain`,`optdt`,`optname`');
$isbg = 0;
if ($this->contain(',' . $rs['distid'] . ',', ',' . $this->adminid . ',')) {
$isbg = 1;
}
$rs['isbg'] = $isbg;
$this->showreturn($rs);
}
示例10: page_load
private function page_load()
{
$this->classDbHelper = new DbHelper("pg_gameclass");
if (isset($_POST['addgame'])) {
if (isset($_POST['gameName']) && isset($_POST['urlColor']) && isset($_POST['gameRank']) && isset($_POST['gameUrl']) && isset($_POST['gameClass'])) {
$this->gameDbHelper = new DbHelper("pg_gamelink");
$gameName = mysql_escape_string($_POST['gameName']);
$urlColor = mysql_escape_string($_POST['urlColor']);
$gameRank = mysql_escape_string($_POST['gameRank']);
$gameUrl = mysql_escape_string($_POST['gameUrl']);
$gameClass = mysql_escape_string($_POST['gameClass']);
$firstword = mysql_escape_string(substr(c($gameName), 0, 1));
if ($this->gameDbHelper->insert('gamename,color,rank,gameUrl,classid,firstword', "'{$gameName}','{$urlColor}','{$gameRank}','{$gameUrl}','{$gameClass}','{$firstword}'")) {
$this->js = "<script>GotoOtherPage('AjaxGameList.php?id=" . $_POST['gameClass'] . "','操作成功!')</script>";
} else {
echo "<script>alert('添加失败,请重试');</script>";
}
}
}
if (isset($_POST['addclass'])) {
if (isset($_POST['className']) && isset($_POST['classRank'])) {
$className = mysql_escape_string($_POST['className']);
$classRank = mysql_escape_string($_POST['classRank']);
if ($this->classDbHelper->insert('className,rank', "'{$className}','{$classRank}'")) {
$this->js = "<script>GotoOtherPage('AjaxGameManage.php','操作成功!')</script>";
} else {
echo "<script>alert('添加失败,请重试');</script>";
}
}
}
$this->classList = $this->classDbHelper->get_many("id>0 order by rank desc");
}
示例11: gdn_dispatcher_beforeDispatch_handler
/**
* Override the default dashboard page with the new stats one.
*/
public function gdn_dispatcher_beforeDispatch_handler($Sender)
{
$Enabled = c('Garden.Analytics.Enabled', true);
if ($Enabled && !Gdn::pluginManager()->hasNewMethod('SettingsController', 'Index')) {
Gdn::pluginManager()->registerNewMethod('VanillaStatsPlugin', 'StatsDashboard', 'SettingsController', 'Index');
}
}
示例12: jisanstatela
public function jisanstatela($table, $rows)
{
$dta = c('date', true);
foreach ($rows as $k => $rs) {
$dt = explode(' ', $rs['optdt']);
$jg = $dta->datediff('d', $dt[0], $this->date);
$str = '';
if ($jg == 0) {
$str = '今天';
} else {
if ($jg == 1) {
$str = '昨天';
} else {
if ($jg == 2) {
$str = '前天';
} else {
if ($jg < 15) {
$str = '' . $jg . '天前';
} else {
$str = '更早';
}
}
}
}
$rows[$k]['temp_atype'] = $str;
$rows[$k]['xuhao'] = $k + 1;
$rows[$k]['optdt'] = $dta->stringdt($rs['optdt']);
}
if (count($rows) == 0) {
$rows[] = array('mess' => '<div style=font-size:16px;height:40px;line-height:35px>无提醒</div>', 'xuhao' => '');
}
return array('wdcount' => m($table)->rows("uid='{$this->adminid}' and `status`=0"), 'rows' => $rows);
}
示例13: loadComponents
function loadComponents()
{
$components = func_get_args();
foreach ($components as $compo) {
require_once c("components") . $compo;
}
}
示例14: importAjax
public function importAjax()
{
$import = c('PHPExcelReader', true);
$cdt = c('date', true);
$rows = $import->reader();
$db = m('admin');
$dbs = m('dept');
$oi = 0;
$sort = (int) $db->getmou('max(`sort`)', '`id`>0') + 1;
foreach ($rows as $k => $rs) {
$arr = array('user' => $rs['A'], 'name' => $rs['B'], 'gender' => $rs['C'], 'ranking' => $rs['D'], 'deptname' => $rs['E'], 'mobile' => $rs['F'], 'email' => $rs['G'], 'workdate' => substr($rs['H'], 1, -1), 'type' => '1', 'state' => '2', 'status' => '1', 'pass' => md5('123456'), 'optdt' => $this->now, 'adddt' => $this->now, 'optid' => $this->adminid, 'optname' => $this->adminname, 'sort' => $sort + $oi);
if (!$this->isempt($arr['user']) && !$this->isempt($arr['name'])) {
if (!$cdt->isdate($arr['workdate'])) {
$arr['workdate'] = '';
}
$msg = $this->isexiset($arr['user'], $arr['name']);
$deptid = (int) $dbs->getmou('id', "`name`='" . $arr['deptname'] . "'");
if ($deptid == 0) {
$arr['deptname'] = '';
}
$arr['deptid'] = $deptid;
if ($msg == '') {
$oi++;
$db->insert($arr);
}
}
}
$this->backmsg('', '成功导入' . $oi . '条,记得更新数据');
}
示例15: _initialize
protected function _initialize()
{
$this->user_session = session('user');
$this->assign('user_session', $this->user_session);
$this->config = d('Config')->get_config();
$this->config['now_city'] = 2035;
$this->assign('config', $this->config);
c('config', $this->config);
$levelDb = m('User_level');
$tmparr = $levelDb->where('22=22')->order('id ASC')->select();
$levelarr = array();
if ($tmparr) {
foreach ($tmparr as $vv) {
$levelarr[$vv['level']] = $vv;
}
}
$this->user_level = $levelarr;
unset($tmparr);
unset($levelarr);
$this->assign('levelarr', $this->user_level);
$this->common_url['group_category_all'] = c('config.site_url') . '/category/all/all';
$this->static_path = $this->config['site_url'] . '/tpl/Static/' . c('DEFAULT_THEME') . '/';
$this->static_public = $this->config['site_url'] . '/static/';
$this->assign('static_path', $this->static_path);
$this->assign('static_public', $this->static_public);
$this->assign($this->common_url);
}