当前位置: 首页>>代码示例>>PHP>>正文


PHP in函数代码示例

本文整理汇总了PHP中in函数的典型用法代码示例。如果您正苦于以下问题:PHP in函数的具体用法?PHP in怎么用?PHP in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了in函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_file

 public function get_file()
 {
     $url = in($_POST['file']);
     $ext = explode('.', $url);
     $ext = end($ext);
     if (function_exists('zip_open')) {
         $url = substr($url, 0, -strlen($ext)) . $ext;
     } else {
         $url = substr($url, 0, -strlen($ext)) . 'gz';
     }
     $file = @Http::doGet($url, 60);
     if (empty($file)) {
         if (function_exists('zip_open')) {
             $this->msg('采用正常模式获取更新文件失败,请稍后再试!', 0);
         } else {
             $this->msg('采用备用模式获取更新文件失败,请稍后再试!', 0);
         }
     }
     $cache_dir = __ROOTDIR__ . '/data/cache/';
     if (!is_dir($cache_dir)) {
         @mkdir($cache_dir, 0777, true);
     }
     if (!@file_put_contents($cache_dir . $this->config['ver_date'] . '.' . $ext, $file)) {
         $this->msg('/data/cache/"目录下文件保存失败,请确认此目录存在或有读写权限!');
         exit;
     }
     $this->msg('/data/cache/' . $this->config['ver_date'] . '.' . $ext, 1);
 }
开发者ID:JamesKid,项目名称:teach,代码行数:28,代码来源:upgradeMod.class.php

示例2: __construct

 public function __construct()
 {
     parent::__construct();
     $this->mobile = in($_POST['mobile']);
     $this->mobile_code = in($_POST['mobile_code']);
     $this->sms_code = in($_POST['sms_code']);
 }
开发者ID:ChanHarold,项目名称:ecshop,代码行数:7,代码来源:SmsController.class.php

示例3: bet

 /**
  * User command for betting on the coin toss game in the casino
  *
  * @param bet int The amount of money to bet on the coin toss game
  * @return Array
  *
  * @note
  * If the player bets within ~1% of the maximum bet, they will receive a reward item
  */
 public function bet()
 {
     $player = new Player(self_char_id());
     $bet = intval(in('bet'));
     $negative = $bet < 0;
     set_setting('bet', max(0, $bet));
     $pageParts = ['reminder-max-bet'];
     if ($negative) {
         $pageParts = ['result-cheat'];
         $player->vo->health = subtractHealth($player->id(), 99);
     } else {
         if ($bet > $player->vo->gold) {
             $pageParts = ['result-no-gold'];
         } else {
             if ($bet > 0 && $bet <= self::MAX_BET) {
                 if (rand(0, 1) === 1) {
                     $pageParts = ['result-win'];
                     $player->vo->gold = add_gold($player->id(), $bet);
                     if ($bet >= round(self::MAX_BET * 0.99)) {
                         // within about 1% of the max bet & you win, you get a reward item.
                         add_item($player->id(), self::REWARD, 1);
                     }
                 } else {
                     $player->vo->gold = subtract_gold($player->id(), $bet);
                     $pageParts = ['result-lose'];
                 }
             }
         }
     }
     // End of not cheating check.
     return $this->render(['pageParts' => $pageParts, 'player' => $player, 'bet' => get_setting('bet')]);
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:41,代码来源:CasinoController.php

示例4: content

 public function content($dir = null, $page = null)
 {
     if (is_numeric($dir)) {
         $aid = intval($dir);
     } else {
         $dir = in($dir);
     }
     if (!empty($aid)) {
         $_GET['aid'] = $aid;
         $_GET['page'] = intval($page);
         module('content')->index();
         return;
     }
     if (!empty($dir)) {
         $lang = model('lang')->langid();
         $content = $this->model->field('A.aid,A.urltitle,B.lang')->table('content', 'A')->add_table('category', 'B', 'A.cid=B.cid')->where('A.urltitle="' . $dir . '" AND B.lang=' . $lang)->find();
         if (empty($content)) {
             $this->error404();
             return;
         } else {
             $_GET['aid'] = $content['aid'];
             $_GET['page'] = intval($page);
             module('content')->index();
             return;
         }
     }
     $this->error404();
     return;
 }
开发者ID:JamesKid,项目名称:teach,代码行数:29,代码来源:rewriteModel.class.php

示例5: requestWork

 /**
  * Take in a url parameter of work and try to convert it to gold
  */
 public function requestWork()
 {
     // Initialize variables to pass to the template.
     $work_multiplier = self::WORK_MULTIPLIER;
     $worked = positive_int(in('worked'));
     // No negative work.
     $earned_gold = null;
     $not_enough_energy = null;
     $recommended_to_work = $worked;
     $is_logged_in = is_logged_in();
     $char_id = self_char_id();
     $char = new Player($char_id);
     $turns = $char->turns();
     $gold = $char->gold();
     if ($worked > $turns) {
         $not_enough_energy = true;
     } else {
         $earned_gold = $worked * $work_multiplier;
         // calc amount worked
         $char->set_gold($gold + $earned_gold);
         $char->set_turns($turns - $worked);
         $char->save();
     }
     $gold_display = number_format($char->gold());
     $parts = ['recommended_to_work' => $recommended_to_work, 'work_multiplier' => $work_multiplier, 'is_logged_in' => $is_logged_in, 'gold_display' => $gold_display, 'worked' => $worked, 'earned_gold' => number_format($earned_gold), 'not_enough_energy' => $not_enough_energy];
     return $this->render($parts);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:30,代码来源:WorkController.php

示例6: changeClass

 /**
  * Action to request class change form AND execute class change
  *
  * @todo split form request and execute into separate funcs
  * @return ViewSpec
  */
 public function changeClass()
 {
     if (is_logged_in()) {
         $player = new Player(self_char_id());
         $classes = $this->classesInfo();
         $requestedIdentity = in('requested_identity');
         $currentClass = $player->identity;
         $showMonks = false;
         $parts = [];
         if (isset($classes[$requestedIdentity])) {
             $error = $this->classChangeReqs($player, self::CLASS_CHANGE_COST);
             if ($currentClass != $requestedIdentity && !$error) {
                 $error = $this->changePlayerClass($player, $requestedIdentity);
             }
             $currentClass = $player->identity;
             if (!$error) {
                 $parts['pageParts'] = ['success-class-change'];
                 $showMonks = true;
             } else {
                 $parts['error'] = $error;
             }
         } else {
             $parts['pageParts'] = ['form-class-change'];
         }
         unset($classes[$currentClass]);
         $parts['classOptions'] = $classes;
         return $this->render($parts, $player, $showMonks);
     } else {
         return $this->accessDenied();
     }
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:37,代码来源:DojoController.php

示例7: testInputWithinEnvironment

 public function testInputWithinEnvironment()
 {
     $id = in('id');
     $this->assertEquals(7, $id);
     $default_result = in('doesnotexist', 5);
     $this->assertEquals(5, $default_result);
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:7,代码来源:environment_test.php

示例8: process

 public function process()
 {
     if (!$this->response instanceof ActionResponse) {
         return;
     }
     $products = $this->response->get('products');
     $ids = array();
     foreach ($products as $key => $product) {
         $ids[$product['ID']] = !empty($product['parentID']) ? $product['parentID'] : $product['ID'];
     }
     if (!$ids) {
         return;
     }
     $f = select(in(f('ProductImage.productID'), array_values($ids)), new LikeCond(f('ProductImage.title'), '%Virtual Mirror%'));
     $hasMirror = array();
     foreach (ActiveRecordModel::getRecordSetArray('ProductImage', $f) as $mirror) {
         $hasMirror[$mirror['productID']] = true;
     }
     foreach ($ids as $realID => $parentID) {
         if (!empty($hasMirror[$parentID])) {
             $hasMirror[$realID] = true;
         }
     }
     foreach ($products as $key => $product) {
         if ($hasMirror[$product['ID']]) {
             $products[$key]['hasMirror'] = true;
         }
     }
     $this->response->set('hasMirror', $hasMirror);
     $this->response->set('products', $products);
 }
开发者ID:saiber,项目名称:www,代码行数:31,代码来源:LoadMirror.php

示例9: bet

 /**
  * User command for betting on the coin toss game in the casino
  *
  * @param bet int The amount of money to bet on the coin toss game
  * @return Array
  *
  * @note
  * If the player bets within ~1% of the maximum bet, they will receive a
  * reward item
  */
 public function bet()
 {
     $player = Player::find(self_char_id());
     $bet = intval(in('bet'));
     $pageParts = ['reminder-max-bet'];
     if ($bet < 0) {
         $pageParts = ['result-cheat'];
         $player->harm(self::CHEAT_DMG);
     } else {
         if ($bet > $player->gold) {
             $pageParts = ['result-no-gold'];
         } else {
             if ($bet > 0 && $bet <= self::MAX_BET) {
                 if (rand(0, 1) === 1) {
                     $pageParts = ['result-win'];
                     $player->set_gold($player->gold + $bet);
                     if ($bet >= round(self::MAX_BET * 0.99)) {
                         // within about 1% of the max bet & you win, you get a reward item.
                         add_item($player->id(), self::REWARD, 1);
                     }
                 } else {
                     $player->set_gold($player->gold - $bet);
                     $pageParts = ['result-lose'];
                 }
             }
         }
     }
     $player->save();
     return $this->render(['pageParts' => $pageParts, 'player' => $player]);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:40,代码来源:CasinoController.php

示例10: chia

function chia($tu1, $mau1, $tu2, $mau2)
{
    // xu ly chia
    $tu3 = $tu1 * $mau2;
    $mau3 = $mau1 * $tu2;
    in($tu1, $mau1, $tu2, $mau2, $tu3, $mau3);
}
开发者ID:agathatruong,项目名称:PHP45,代码行数:7,代码来源:phanso.php

示例11: in

function in($t, $arrays = true, $keyEncode = '')
{
    if (is_array($t)) {
        if ($arrays) {
            $b = array();
            foreach ($t as $i) {
                $n = array();
                foreach ($i as $k => $v) {
                    $n[chgName($k)] = $v;
                }
                $n['_' . chgName($keyEncode)] = in($i[$keyEncode]);
                array_push($b, $n);
            }
            return $b;
        } else {
            $n = array();
            foreach ($t as $k => $v) {
                $n[chgName($k)] = $v;
            }
            $n['_' . chgName($keyEncode)] = in($t[$keyEncode]);
            return $n;
        }
    } else {
        $encode = base64_encode(time());
        return base64_encode(str_pad(strlen($encode), 3, '0', STR_PAD_LEFT) . $encode . base64_encode($t));
    }
}
开发者ID:bbarbosa0604,项目名称:php-default-project,代码行数:27,代码来源:functions.php

示例12: index

 public function index()
 {
     $type = $_GET['type'];
     if (!empty($type)) {
         $url_type = '-type-' . $type;
         if ($type == 'no') {
             $where = 'type is Null';
         } else {
             $where = 'type="' . $type . '"';
         }
     }
     $ext = intval($_GET['ext']);
     if (!empty($ext)) {
         $ext1 = '"jpg","gif","jpeg","bmp","png"';
         $ext2 = '"flv","wmv","wma","mp3","jpeg","mp4","3gp","avi","swf","mkv"';
         $ext3 = '"doc","xsl","wps","docx","xslx","ppt","pptx"';
         $ext4 = '"zip","rar","7z"';
         $ext5 = $ext1 . ',' . $ext2 . ',' . $ext3 . ',' . $ext4;
         $url_ext = '-ext-' . $ext;
         switch ($ext) {
             case 1:
                 $where = 'ext in(' . $ext1 . ')';
                 break;
             case 2:
                 $where = 'ext in(' . $ext2 . ')';
                 break;
             case 3:
                 $where = 'ext in(' . $ext3 . ')';
                 break;
             case 4:
                 $where = 'ext in(' . $ext4 . ')';
                 break;
             case 5:
                 $where = 'ext not in(' . $ext5 . ')';
                 break;
         }
     }
     $search = in(urldecode($_GET['search']));
     if (!empty($search)) {
         $where = ' title like "%' . $search . '%"';
         $url_search = '-search-' . $search;
     }
     //分页处理
     //分页信息
     $url = __URL__ . '/index/page-{page}' . $url_type . $url_ext . $url_search;
     //分页基准网址
     $listRows = 50;
     $page = new Page();
     $cur_page = $page->getCurPage($url);
     $limit_start = ($cur_page - 1) * $listRows;
     $limit = $limit_start . ',' . $listRows;
     //内容列表
     $this->list = model('upload')->file_list($where, $limit);
     //统计总内容数量
     $count = model('upload')->count($where);
     $this->assign('page', $this->page($url, $count, $listRows));
     $this->module_list = model('upload')->module_list();
     $this->show();
 }
开发者ID:JamesKid,项目名称:teach,代码行数:59,代码来源:upload_fileMod.class.php

示例13: deleteEnemy

 /**
  * Take an enemy off a pc's list.
  */
 public function deleteEnemy()
 {
     $remove_enemy = in('remove_enemy', null, 'toInt');
     if (is_numeric($remove_enemy) && $remove_enemy != 0) {
         $this->removeEnemyFromPlayer(self_char_id(), $remove_enemy);
     }
     return new RedirectResponse('enemies.php');
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:11,代码来源:ConsiderController.php

示例14: check_for_debug

function check_for_debug()
{
    $dbg = in('debug');
    if ($dbg == 'on') {
        $_COOKIE['debug'] == true;
    } elseif ($dbg == 'off') {
        $_COOKIE['debug'] == false;
    }
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:9,代码来源:lib_debug.php

示例15: index

 /**
  * Display that list of public quests!
  */
 public function index()
 {
     $quest_id = in('quest_id');
     $quest_accepted = in('quest_accepted');
     $quests = format_quests(get_quests());
     $title = 'Quests';
     $tpl = 'quests.tpl';
     $parts = ['quests' => $quests];
     return ['template' => $tpl, 'title' => $title, 'parts' => $parts, 'options' => null];
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:13,代码来源:QuestController.php


注:本文中的in函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。