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


PHP any函数代码示例

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


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

示例1: create

 /** Creates directory or throws exception on fail
  * @param string $pathname
  * @param int    $mode     Mode in octal
  * @return bool
  */
 public static function create($pathname, $mode = self::MOD_DEFAULT)
 {
     if (strpos($pathname, '/') !== false) {
         $pathname = explode('/', $pathname);
     }
     if (is_array($pathname)) {
         $current_dir = '';
         $create = array();
         do {
             $current_dir = implode('/', $pathname);
             if (is_dir($current_dir)) {
                 break;
             }
             $create[] = array_pop($pathname);
         } while (any($pathname));
         if (any($create)) {
             $create = array_reverse($create);
             $current_dir = implode('/', $pathname);
             foreach ($create as $dir) {
                 $current_dir .= '/' . $dir;
                 if (!is_dir($current_dir)) {
                     if (!($action = @mkdir($current_dir, $mode))) {
                         throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $current_dir, base_convert($mode, 10, 8)));
                     }
                 }
             }
         }
     } else {
         if (!($action = @mkdir($pathname, $mode, true))) {
             throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $pathname, base_convert($mode, 10, 8)));
         }
     }
     return $action;
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:39,代码来源:directory.php

示例2: get_new

 static function get_new()
 {
     try {
         $old_items = static::get_all()->fetch();
     } catch (\System\Error $e) {
         $old_items = array();
     }
     $old = array();
     foreach ($old_items as &$m) {
         $old[] = $m->date->format('sql') . '-' . $m->seoname;
     }
     $items = self::checkout_folder($old);
     if (any($items)) {
         $sums = collect(array('attr', 'md5_sum'), $items, true);
         try {
             $old = static::get_all(array("t0.md5_sum IN ('" . implode("','", $sums) . "')"))->fetch();
         } catch (\System\Error $e) {
             $old = array();
         }
     }
     foreach ($old as $mig) {
         foreach ($items as $key => $nmig) {
             if ($mig->get_checksum() == $nmig->get_checksum()) {
                 if ($mig->status == 'ok') {
                     unset($items[$key]);
                 } else {
                     $items[$key] = $mig;
                 }
             }
         }
     }
     uasort($items, array('self', 'sort'));
     return $items;
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:34,代码来源:migration.php

示例3: controller_waypoints

 function controller_waypoints($args, $output = "inline")
 {
     $location["tr"] = explode(",", $args["tr"]);
     $location["bl"] = explode(",", $args["bl"]);
     $location["tl"] = array($location["tr"][0], $location["bl"][1]);
     $location["br"] = array($location["bl"][0], $location["tr"][1]);
     $location["center"] = array($location["bl"][0] + ($location["tr"][0] - $location["bl"][0]) / 2, $location["bl"][1] + ($location["tr"][1] - $location["bl"][1]) / 2);
     $zoom = any($args["zoom"], 1);
     $yelp = new Yelp();
     $wherestr = "WHERE {NavigationLocation.lat} <= " . mysql_escape_string($location["tr"][0]) . " AND {NavigationLocation.lat} >= " . mysql_escape_string($location["bl"][0]);
     $wherestr .= " AND {NavigationLocation.lon} <= " . mysql_escape_string($location["tr"][1]) . " AND {NavigationLocation.lon} >= " . mysql_escape_string($location["bl"][1]);
     $wherestr .= " AND {NavigationLocation.zoom_min} <= " . mysql_escape_string($zoom) . " AND {NavigationLocation.zoom_max} >= " . mysql_escape_string($zoom);
     $wherestr .= " AND {NavigationLocation.name} != 'mapcenter'";
     $locations_center = $this->conn->load("NavigationLocation", "mapcenter");
     if (empty($locations_center)) {
         $locations_center = new NavigationLocation();
         $locations_center->locationid = "mapcenter";
         $locations_center->name = "mapcenter";
         $locations_center->type = "hidden";
     }
     $locations_center->lat = $location["center"][0];
     $locations_center->lon = $location["center"][1];
     $locations_center->zoom_min = $zoom;
     $locations_center->zoom_max = $zoom;
     $this->conn->save($locations_center);
     $locations_db = $this->conn->select("NavigationLocation", $wherestr);
     $locations_yelp = $yelp->getReviews($location);
     if (is_array($locations_db) && is_array($locations_yelp)) {
         $locations = array_merge($locations_yelp, $locations_db);
     } else {
         $locations = any($locations_db, $locations_yelp);
     }
     $ret = json_encode($locations);
     return $ret;
 }
开发者ID:ameyer430,项目名称:elation,代码行数:35,代码来源:supercritical_navigation.php

示例4: lookup

 public static function lookup($hostname)
 {
     self::init();
     Profiler::StartTimer("DNSResolver::lookup()", 2);
     $data = DataManager::singleton();
     $records = $apc = NULL;
     $cachekey = "dnsresolver.lookup.{$hostname}";
     if (self::$cache && !empty($data->caches["apc"]) && $data->caches["apc"]["default"]->enabled) {
         $apc = $data->caches["apc"]["default"];
         $cached = $apc->get($cachekey);
         if ($cached !== false) {
             $records = unserialize($cached);
             Logger::Info("DNSResolver: found '{$hostname}' in APC cache");
         }
     }
     if ($records === NULL) {
         Logger::Info("DNSResolver: Looking up '{$hostname}'");
         foreach (self::$search as $suffix) {
             $fqdn = $hostname . (!empty($suffix) ? "." . $suffix : "");
             $records = dns_get_record($fqdn, DNS_A);
             if (!empty($records)) {
                 break;
             }
         }
         if (self::$cache && !empty($records) && $apc !== NULL && $apc->enabled) {
             $ttl = any(self::$ttl, $records[0]["ttl"]);
             $apc->set($cachekey, serialize($records), array("lifetime" => $ttl));
         }
     }
     Profiler::StopTimer("DNSResolver::lookup()");
     return $records;
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:32,代码来源:dnsresolver_class.php

示例5: _createMessageWithByteCount

 private function _createMessageWithByteCount($bytes)
 {
     $this->_bytes = $bytes;
     $msg = $this->_mock('Swift_Mime_Message');
     $this->_checking(Expectations::create()->ignoring($msg)->toByteStream(any())->calls(array($this, '_write')));
     return $msg;
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-quick-start-cn,代码行数:7,代码来源:ThrottlerPluginTest.php

示例6: controller_account

 function controller_account($args)
 {
     if (!User::authorized("mail")) {
         throw new Exception("not allowed");
     }
     $vars["account"] = any($args["account"], $args["item"]);
     return $this->GetComponentResponse("./account.tpl", $vars);
 }
开发者ID:ameyer430,项目名称:elation,代码行数:8,代码来源:mail.php

示例7: __construct

 function __construct($locations = NULL)
 {
     $dbdir = any($locations['tmp'], 'tmp');
     if (class_exists("Outlet")) {
         Outlet::init(array('connection' => array('type' => 'datamanager'), 'classes' => array()));
         $this->outlet =& Outlet::getInstance();
     }
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:8,代码来源:ormmanager_class.php

示例8: test_any

 public function test_any()
 {
     ensure(any(array(1, 2, 3), function ($v) {
         return $v > 2;
     }));
     ensure(!any(array(1, 2, 3), function ($v) {
         return $v > 4;
     }));
 }
开发者ID:jaz303,项目名称:php-helpers,代码行数:9,代码来源:functional_test.php

示例9: controller_irc

 public function controller_irc($args)
 {
     $vars = array();
     $vars["host"] = any($args["host"], array_get($_SESSION, "irc.host"), "irc.freenode.net");
     $vars["port"] = any($args["port"], array_get($_SESSION, "irc.port"), 6667);
     $vars["nick"] = any($args["nick"], array_get($_SESSION, "irc.nickname"), sprintf("peon%04d", rand(0, 9999)));
     array_set($_SESSION, "irc.nickname", $vars["nick"]);
     return $this->GetComponentResponse("./irc.tpl", $vars);
 }
开发者ID:jun0813,项目名称:elation-irc,代码行数:9,代码来源:irc.php

示例10: shouldNotRelyOnArryIndexesWhenUnwrappingToASingleResolutionValue

 /** @test */
 public function shouldNotRelyOnArryIndexesWhenUnwrappingToASingleResolutionValue()
 {
     $mock = $this->createCallableMock();
     $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(2));
     $d1 = new Deferred();
     $d2 = new Deferred();
     any(['abc' => $d1->promise(), 1 => $d2->promise()])->then($mock);
     $d2->resolve(2);
     $d1->resolve(1);
 }
开发者ID:453111208,项目名称:bbc,代码行数:11,代码来源:FunctionAnyTest.php

示例11: whenTokenIsExpired

 /**
  * @test
  */
 public function whenTokenIsExpired()
 {
     require realpath(__DIR__ . '/../../../') . '/etc/app.php';
     $db = $this->createMockDb();
     $user = array_merge($this->createFixtureUser(), array('token_timestamp' => time() - TOKEN_VALID_TIME - 1));
     $db->expects(any())->method('findUserByToken')->will(returnValue($user));
     $checker = $this->createTokenChecker($db);
     $request = $this->createValidRequest();
     $this->assertErrorResponse(403, 'Token expired', $checker($request, $app));
 }
开发者ID:ashishkalranitk,项目名称:Spika-Server,代码行数:13,代码来源:TokenCheckerTest.php

示例12: testSettingCharsetClearsCache

 public function testSettingCharsetClearsCache()
 {
     $headers = $this->_createHeaderSet(array(), false);
     $this->_checking(Expectations::create()->ignoring($headers)->toString()->returns("Content-Type: text/plain; charset=utf-8\r\n")->ignoring($headers));
     $cache = $this->_createCache(false);
     $this->_checking(Expectations::create()->one($cache)->clearKey(any(), 'body')->ignoring($cache));
     $entity = $this->_createEntity($headers, $this->_createEncoder(), $cache);
     $entity->setBody("blah\r\nblah!");
     $entity->toString();
     $entity->setCharset('iso-2022');
 }
开发者ID:Fyflon,项目名称:MTA-XyzzyRP,代码行数:11,代码来源:MimePartTest.php

示例13: controller_exists

 public function controller_exists($args)
 {
     $vars["usertype"] = any($args["usertype"], "default");
     $vars["userid"] = $args["userid"];
     $user = false;
     if (!empty($vars["userid"])) {
         $user = User::get($vars["usertype"], $vars["userid"]);
     }
     $vars["success"] = !empty($user);
     return $this->GetComponentResponse("./exists.tpl", $vars);
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:11,代码来源:user.php

示例14: run_tasks

 /** Run callbacks
  * @param string $trigger Name of trigger to fier
  * @param array  $args    Data to pass
  * @return void
  */
 public function run_tasks($trigger, array $args = array())
 {
     if (any($this::$callbacks[$trigger])) {
         foreach ($this::$callbacks[$trigger] as $task) {
             if (is_callable(array($this, $task))) {
                 $this->{$task}($args);
             } else {
                 throw new \System\Error\Model(sprintf('Invalid callback "%s" for "%s"', $task, $trigger));
             }
         }
     }
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:17,代码来源:callback.php

示例15: compile

 private function compile(array $tokens)
 {
     $cg = (object) ['ts' => TokenStream::fromSlice($tokens), 'parsers' => []];
     traverse(rtoken('/^(T_\\w+)·(\\w+)$/')->onCommit(function (Ast $result) use($cg) {
         $token = $result->token();
         $id = $this->lookupCapture($token);
         $type = $this->lookupTokenType($token);
         $cg->parsers[] = token($type)->as($id);
     }), ($parser = chain(rtoken('/^·\\w+$/')->as('type'), token('('), optional(ls(either(future($parser)->as('parser'), chain(token(T_FUNCTION), parentheses()->as('args'), braces()->as('body'))->as('function'), string()->as('string'), rtoken('/^T_\\w+·\\w+$/')->as('token'), rtoken('/^T_\\w+$/')->as('constant'), rtoken('/^·this$/')->as('this'), label()->as('label'))->as('parser'), token(',')))->as('args'), commit(token(')')), optional(rtoken('/^·\\w+$/')->as('label'), null)))->onCommit(function (Ast $result) use($cg) {
         $cg->parsers[] = $this->compileParser($result->type, $result->args, $result->label);
     }), $this->layer('{', '}', braces(), $cg), $this->layer('[', ']', brackets(), $cg), $this->layer('(', ')', parentheses(), $cg), rtoken('/^···(\\w+)$/')->onCommit(function (Ast $result) use($cg) {
         $id = $this->lookupCapture($result->token());
         $cg->parsers[] = layer()->as($id);
     }), token(T_STRING, '·')->onCommit(function (Ast $result) use($cg) {
         $offset = \count($cg->parsers);
         if (0 !== $this->dominance || 0 === $offset) {
             $this->fail(self::E_BAD_DOMINANCE, $offset, $result->token()->line());
         }
         $this->dominance = $offset;
     }), rtoken('/·/')->onCommit(function (Ast $result) {
         $token = $result->token();
         $this->fail(self::E_BAD_CAPTURE, $token, $token->line());
     }), any()->onCommit(function (Ast $result) use($cg) {
         $cg->parsers[] = token($result->token());
     }))->parse($cg->ts);
     // check if macro dominance '·' is last token
     if ($this->dominance === \count($cg->parsers)) {
         $this->fail(self::E_BAD_DOMINANCE, $this->dominance, $cg->ts->last()->line());
     }
     $this->specificity = \count($cg->parsers);
     if ($this->specificity > 1) {
         if (0 === $this->dominance) {
             $pattern = chain(...$cg->parsers);
         } else {
             /*
               dominat macros are partially wrapped in commit()s and dominance
               is the offset used as the 'event horizon' point... once the entry
               point is matched, there is no way back and a parser error arises
             */
             $prefix = array_slice($cg->parsers, 0, $this->dominance);
             $suffix = array_slice($cg->parsers, $this->dominance);
             $pattern = chain(...array_merge($prefix, array_map(commit::class, $suffix)));
         }
     } else {
         /*
           micro optimization to save one function call for every token on the subject
           token stream whenever the macro pattern consists of a single parser
         */
         $pattern = $cg->parsers[0];
     }
     return $pattern;
 }
开发者ID:lastguest,项目名称:yay,代码行数:52,代码来源:Pattern.php


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