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


PHP Arrays::exists方法代码示例

本文整理汇总了PHP中Arrays::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::exists方法的具体用法?PHP Arrays::exists怎么用?PHP Arrays::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arrays的用法示例。


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

示例1: run

 public function run($function, array $params = array())
 {
     $hooks = Utils::get('ThinHooks');
     $res = null;
     if (Arrays::exists($function, $hooks)) {
         if (Arrays::exists('before', $hooks[$function])) {
             $action = $hooks[$function]['before'];
             if (is_callable($action, true, $before)) {
                 $res = $before();
             }
         }
         if (null === $res) {
             $res = '';
         }
         $res .= call_user_func_array($function, $params);
         if (Arrays::exists('after', $hooks[$function])) {
             $action = $hooks[$function]['after'];
             if (is_callable($action, true, $after)) {
                 $res .= $after();
             }
         }
         return $res;
     } else {
         return call_user_func_array($function, $params);
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:26,代码来源:Hook.php

示例2: instance

 /**
  * Static method for instantiating a singleton object.
  *
  * @return object
  */
 public static final function instance()
 {
     $className = get_called_class();
     if (!Arrays::exists(static::$instances[$className])) {
         static::$instances[$className] = new $className(func_get_args());
     }
     return static::$instances[$className];
 }
开发者ID:schpill,项目名称:thin,代码行数:13,代码来源:Singleton.php

示例3: get

 /**
  * @param string $name
  * @return mixed
  */
 public static function get($name, $default = null)
 {
     if (Arrays::exists($name, $_COOKIE)) {
         if (isset($_COOKIE[$name])) {
             return $_COOKIE[$name];
         }
     }
     return $default;
 }
开发者ID:schpill,项目名称:thin,代码行数:13,代码来源:Cookies.php

示例4: isPost

 public function isPost($except = [])
 {
     if (!empty($_POST) && !empty($except)) {
         foreach ($except as $key) {
             if (Arrays::exists($key, $_POST)) {
                 unset($_POST[$key]);
             }
         }
     }
     return !empty($_POST);
 }
开发者ID:schpill,项目名称:standalone,代码行数:11,代码来源:Controller.php

示例5: flush

 public static function flush($queue)
 {
     foreach (static::$flushers[$queue] as $flusher) {
         if (!Arrays::exists($queue, static::$queued)) {
             continue;
         }
         foreach (static::$queued[$queue] as $key => $payload) {
             array_unshift($payload, $key);
             call_user_func_array($flusher, $payload);
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:12,代码来源:Event.php

示例6: next

 private static function next($url, $data)
 {
     $tab = json_decode(file_get_contents($url), true);
     $data = array_merge($data, $tab['data']);
     if (Arrays::exists('next', $tab)) {
         $next = $tab['next'];
         if (isset($next)) {
             return static::next($next, $data);
         }
     }
     return $data;
 }
开发者ID:schpill,项目名称:thin,代码行数:12,代码来源:Music.php

示例7: get

 public function get($key)
 {
     if ($this->useCache && Arrays::exists($key, $this->cache)) {
         return $this->cache[$key];
     }
     $v = dba_fetch($key, $this->dbHandler);
     // convert
     $value = $this->decode($v);
     // store
     if ($this->useCache) {
         $this->cache[$key] = $value;
     }
     return $value;
 }
开发者ID:schpill,项目名称:thin,代码行数:14,代码来源:Dba.php

示例8: __construct

 public function __construct($config)
 {
     $session = session('web');
     $session->setLanguage($config->getLanguage());
     $this->_config = $config;
     if ($config->getLanguage() == Cms::getOption('default_language')) {
         $this->_needTranslate = false;
     } else {
         $file = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $config->getModule() . DS . 'languages' . DS . $config->getController() . ucFirst($config->getLanguage()) . '.php';
         $this->_translation = new languageTranslation();
         if (File::exists($file)) {
             $translation = (include $file);
             $this->_translation->populate(Arrays::exists($config->getAction(), $translation) ? $translation[$config->getAction()] : $translation);
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:16,代码来源:Language.php

示例9: getCategories

 public static function getCategories()
 {
     $collection = array();
     $articles = static::getAll();
     foreach ($articles as $tmpArticle) {
         $article = static::getArticle($tmpArticle);
         $cat = $article->getCategory();
         if (!Arrays::exists($cat, $collection)) {
             $collection[$cat] = 1;
         } else {
             $collection[$cat]++;
         }
     }
     ksort($collection);
     return $collection;
 }
开发者ID:schpill,项目名称:thin,代码行数:16,代码来源:Blog.php

示例10: getNamedInterval

 function getNamedInterval($id = null)
 {
     # if $id name is null
     if ($id === null) {
         # return the latest interval
         foreach ($this->intervals as $id => $val) {
         }
         $ret = "{$id} = {$val}";
         # else if there is a $id name
     } elseif (Arrays::exists($id, $this->intervals)) {
         # return the named interval
         $ret = "{$id} = {$this->intervals[$id]}";
     } else {
         $ret = "{$id} = no value";
     }
     return $ret;
 }
开发者ID:schpill,项目名称:thin,代码行数:17,代码来源:Interval.php

示例11: __construct

 public function __construct(array $connection)
 {
     $required = array('host', 'port', 'secure', 'auth', 'login', 'password', 'debug');
     foreach ($required as $field) {
         if (!Arrays::exists($field, $connection)) {
             throw new Exception($field . " is mandatory to use this class.");
         }
     }
     // set connection vars
     $this->host = $connection['host'];
     $this->port = $connection['port'];
     $this->secure = $connection['secure'];
     $this->auth = $connection['auth'];
     $this->user = $connection['login'];
     $this->pass = $connection['password'];
     // set debug mode
     $this->debugMode = $connection['debug'];
 }
开发者ID:schpill,项目名称:thin,代码行数:18,代码来源:Smtp.php

示例12: add

 /**
  * Add a row to the cart
  *
  * @param string|Array $id      Unique ID of the item|Item formated as array|Array of items
  * @param string       $name    Name of the item
  * @param int          $qty     Item qty to add to the cart
  * @param float        $price   Price of one item
  * @param Array        $options Array of additional options, such as 'size' or 'color'
  */
 public function add($id, $name = null, $qty = null, $price = null, array $options = array())
 {
     // If the first parameter is an array we need to call the add() function again
     if (Arrays::is($id)) {
         // And if it's not only an array, but a multidimensional array, we need to
         // recursively call the add function
         if ($this->isMulti($id)) {
             foreach ($id as $item) {
                 $options = Arrays::exists('options', $item) ? $item['options'] : array();
                 $this->addRow($item['id'], $item['name'], $item['qty'], $item['price'], $options);
             }
             return;
         }
         $options = Arrays::exists('options', $id) ? $id['options'] : array();
         return $this->addRow($id['id'], $id['name'], $id['qty'], $id['price'], $options);
     }
     return $this->addRow($id, $name, $qty, $price, $options);
 }
开发者ID:schpill,项目名称:thin,代码行数:27,代码来源:Cart.php

示例13: auto

 public static function auto($sentence, $source = 'fr', $target = 'en')
 {
     $key = sha1(serialize(func_get_args()));
     $res = Data::query('translation', 'key = ' . $key);
     if (count($res)) {
         $obj = current($res);
         return $obj->getSentence();
     }
     $source = Inflector::lower($source);
     $target = Inflector::lower($target);
     $url = "http://api.mymemory.translated.net/get?q=" . urlencode($sentence) . "&langpair=" . urlencode($source) . "|" . urlencode($target);
     $res = dwn($url);
     $tab = json_decode($res, true);
     if (Arrays::exists('responseData', $tab)) {
         if (Arrays::exists('translatedText', $tab['responseData'])) {
             $translation = $tab['responseData']['translatedText'];
             $data = array('source' => $source, 'target' => $target, 'key' => $key, 'sentence' => $translation);
             Data::add('translation', $data);
             return $translation;
         }
     }
     return $sentence;
 }
开发者ID:schpill,项目名称:thin,代码行数:23,代码来源:Translation.php

示例14: getVariableName

 function getVariableName()
 {
     $arrBacktrace = debug_backtrace();
     //possible 'included' functions
     $arrInclude = array("include", "include_once", "require", "require_once");
     //check for any included/required files. if found, get array of the last included file (they contain the right line numbers)
     $countBt = count($arrBacktrace);
     for ($i = $countBt - 1; $i >= 0; $i--) {
         $arrCurrent = $arrBacktrace[$i];
         if (Arrays::exists("function", $arrCurrent) && (Arrays::inArray($arrCurrent["function"], $arrInclude) || 0 != strcasecmp($arrCurrent["function"], "dbug"))) {
             continue;
         }
         $arrFile = $arrCurrent;
         break;
     }
     if (isset($arrFile)) {
         $arrLines = file($arrFile["file"]);
         $code = $arrLines[$arrFile["line"] - 1];
         //find call to dBug class
         preg_match('/\\bnew dBug\\s*\\(\\s*(.+)\\s*\\);/i', $code, $arrMatches);
         return $arrMatches[1];
     }
     return "";
 }
开发者ID:schpill,项目名称:thin,代码行数:24,代码来源:Info.php

示例15: newInstance

 public function newInstance($id = null)
 {
     if (null === $id) {
         $obj = new self($this->_entity, $this->_table);
         $obj = $obj->map();
         foreach ($obj->fields() as $field) {
             if (Arrays::is($obj->_datas['keys'])) {
                 if (Arrays::in($field, $obj->_datas['keys'])) {
                     if (Arrays::exists($field, $obj->_datas['configModel']['relationship'])) {
                         $seg = $obj->_datas['configModel']['relationship'][$field];
                         $m = $obj->_datas['configModel']['relationship'][$field];
                         if (null !== $m) {
                             $obj->_datas['foreignFields'][$field] = true;
                         }
                     }
                 }
             }
         }
         return $obj;
     } else {
         $obj = new $class();
         return $obj->find($id);
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:24,代码来源:Orm.php


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