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


PHP arr::hasKey方法代码示例

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


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

示例1: offsetUnset

 public function offsetUnset($offset)
 {
     if (!arr::hasKey($this->data, $offset)) {
         return;
     }
     unset($this->data[$offset]);
     sort($this->data);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:request.php

示例2: get

 static function get($name, $default = null)
 {
     if (arr::hasKey(self::$cookies, $name)) {
         return self::$cookies[$name];
     } else {
         return $default;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:cookies.php

示例3: __construct

 /**
  * Constructor
  *
  * @param string $uri The URI to route
  * @param string $domain The domain to route
  * @param bool $secure True if connection made via SSL
  */
 public function __construct($buri = '/')
 {
     if (isset($_SERVER['REQUEST_URI'])) {
         $uri = $_SERVER['REQUEST_URI'];
     } else {
         $uri = $buri;
     }
     if (isset($_SERVER['HTTP_HOST'])) {
         $domain = strtolower($_SERVER['HTTP_HOST']);
     } else {
         if (isset($_SERVER['SERVER_NAME'])) {
             $domain = strtolower($_SERVER['SERVER_NAME']);
         } else {
             $domain = 'localhost';
         }
     }
     $secure = true;
     // Parse query string
     if (strpos($uri, '?')) {
         $base = substr($uri, 0, strpos($uri, '?'));
         $rest = substr($uri, strpos($uri, '?') + 1);
         // Apache mod_rewrite workaround for existing folders - requests
         // are routed as /uri/?/uri if the folder exists.
         if ($base != '/' && file_exists('.' . $base) && substr($rest, 0, strlen($base) - 1) . '/' == $base) {
             // folder match, reroute the $rest.
             // TODO: Query string arguments should be passed on
             if (strpos($rest, '&') > 0) {
                 $params = substr($rest, strpos($rest, '&') + 1);
             }
             response::redirect($base . '?' . $params);
         } else {
             // Parse the querystring
             $qsl = explode('&', $rest);
             foreach ($qsl as $qsi) {
                 if (preg_match('/^(.*)=(.*)$/', $qsi, $keys)) {
                     $_GET[$keys[1]] = urldecode($keys[2]);
                     $_REQUEST[$keys[1]] = urldecode($keys[2]);
                 }
             }
             $uri = $base;
         }
     }
     // Quick fix for first index being '/index_php' when invoked via
     // apache - hopefully sorts bug with php oauth.
     if (arr::hasKey($_GET, '/index_php')) {
         array_shift($_GET);
         array_shift($_GET);
     }
     // Assign the URI and start parsing
     $this->_uri = $uri;
     $this->_domain = $domain;
     $this->_secure = request::isSecure();
     foreach (explode('/', $this->_uri) as $segment) {
         if ($segment != '') {
             $this->_urisegments[] = $segment;
         }
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:65,代码来源:router.php

示例4: addAnimator

 public function addAnimator($property, ILpfAnimator $animator, $frstart, $frend)
 {
     if (arr::hasKey($this->_properties, $property)) {
         $this->_animators[$property][] = array('animator' => $animator, 'framestart' => $frstart, 'frameend' => $frend);
         console::writeLn("Attached animator: %s => %s", typeOf($animator), $property);
     } else {
         logger::warning("Animator attached to nonexisting property %s of object %s", $property, (string) $this->_object);
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:9,代码来源:scenegraph.php

示例5: __construct

 function __construct($structure = null)
 {
     $path = expandpath('app:' . $structure);
     if (file_exists($path) && $structure) {
         $strx = domdocument::load($path);
         $domx = new DOMXpath($strx);
         $cfgs = $domx->query('/configurationschema/config');
         foreach ($cfgs as $item) {
             $key = $item->getAttribute('key');
             if ($item->hasAttribute('type')) {
                 $vartype = $item->getAttribute('type');
             } else {
                 $vartype = 'string';
             }
             $description = null;
             $default = null;
             if ($item->childNodes->length > 0) {
                 foreach ($item->childNodes as $item) {
                     switch ($item->nodeName) {
                         case 'default':
                             $value = $item->getAttribute('value');
                             $type = $item->getAttribute('type');
                             if ($type == 'string') {
                                 $value = str_replace('${servername}', request::getDomain(), $value);
                                 $default = $value;
                             }
                             if ($type == 'integer') {
                                 $value = intval($value);
                                 $default = $value;
                             }
                             if ($type == 'float') {
                                 $value = floatval($value);
                                 $default = $value;
                             }
                             if ($type == 'generate') {
                                 if ($value == 'uuid') {
                                     $default = uuid::v4();
                                 } else {
                                     $default = '<unknown>';
                                 }
                             }
                             break;
                         case 'description':
                             $description = $item->nodeValue;
                             break;
                     }
                 }
             }
             if (!arr::hasKey($this->data, $key)) {
                 $this->data[$key] = $default;
             }
             $this->defs[$key] = array('description' => $description, 'vartype' => $vartype);
         }
         $this->flush();
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:56,代码来源:prefs.php

示例6: getPooledConnection

 /**
  * @brief Return a pooled connection for the connectionstring
  *
  * @param mixed $connectionstring The connectionstring to request
  * @return DatabaseDriver the database driver
  */
 public static function getPooledConnection($connectionstring)
 {
     $csh = md5(serialize($connectionstring));
     if (!arr::hasKey(self::$pool, $csh)) {
         $driverclass = DatabaseDriver::getDriverClass($connectionstring['driver']);
         self::$pool[$csh] = array('instance' => new $driverclass($connectionstring), 'count' => 0);
         self::$pool[$csh]['instance']->setPoolIdentity($csh);
     }
     self::$pool[$csh]['count']++;
     return self::$pool[$csh]['instance'];
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:17,代码来源:databaseconnectionpool.php

示例7: invoke

 /**
  * Invoke a specif event
  *
  * @param Mixed $event The event to invoke
  * @param Array $data The data to pass to the handler
  */
 static function invoke($event, array $data)
 {
     if (arr::hasKey(self::$_handlers, strtolower($event))) {
         foreach (self::$_handlers[$event] as $evt) {
             if ($evt->dispatch($event, $data) == true) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:17,代码来源:events.php

示例8: __set

 public function __set($property, $value)
 {
     if (arr::hasKey($this->properties, $property)) {
         $ptype = $this->properties[$property]['type'];
         $val = lpf::cast($value, $ptype);
         $this->properties[$property]['value'] = $val;
         list($type) = explode(':', $ptype);
         return;
     }
     printf("No such property %s\n", $property);
     return null;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:12,代码来源:actor.php

示例9: __get

 public function __get($property)
 {
     if (arr::hasKey($this->properties, $property)) {
         $propmeta = $this->properties[$property];
         if ($propmeta['propget']) {
             return $propmeta['propget']($property);
         } else {
             return $this->properties['value'];
         }
     } else {
         logger::warning("Ambient property %s requested object %s", $property, $this);
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:13,代码来源:object.php

示例10: __construct

 function __construct($pms)
 {
     if (!globals::get('pantonescale')) {
         die("pantone.dat not found!");
     }
     $vals = globals::get('pantonescale');
     if (!arr::hasKey($vals, strtoupper($pms))) {
         throw new ColorException(sprintf("Pantone color %s not known!", $pms));
     }
     $val = $vals[strtoupper($pms)];
     $this->red = $val['r'];
     $this->green = $val['g'];
     $this->blue = $val['b'];
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:14,代码来源:pantone.php

示例11: _streamDoRequest

 private function _streamDoRequest()
 {
     $options = $this->args;
     $ctxparam = array('http' => array('method' => strtolower($options['method']) == 'post' ? 'POST' : 'GET'));
     if (arr::hasKey($options, 'parameters')) {
         $ctxparam['http']['content'] = http_build_query($options['parameters']);
     }
     $ctx = stream_context_create($ctxparam);
     $cfh = fopen($url, 'r', false, $ctx);
     $buf = '';
     while (!feof($cfh)) {
         $buf .= fread($cfh, 8192);
     }
     fclose($cfh);
     $this->ret = array('content' => $buf);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:16,代码来源:httprequest.php

示例12: parsefield

 function parsefield($data)
 {
     $str = $data[1];
     $strx = explode(' ', $str);
     $svar = $strx[0];
     if (arr::hasKey($this->_vars, $svar)) {
         $rval = $this->_vars[$svar];
     } else {
         $rval = "[" . $svar . "]";
     }
     $indent = 0;
     $wrap = 0;
     foreach (array_slice($strx, 1) as $strs) {
         $alist = explode(':', $strs);
         switch ($alist[0]) {
             case 'indent':
                 $indent = intval($alist[1]);
                 break;
             case 'wrap':
                 $wrap = intval($alist[1]);
                 break;
         }
     }
     $buf = explode("\n", $rval);
     foreach ($buf as $bufitem) {
         $rval = $bufitem;
         if ($wrap > 0) {
             $rv = array();
             $rvalarr = explode("\n", $rval);
             foreach ($rvalarr as $line) {
                 $rv[] = wordwrap($line, $wrap - $indent);
             }
             $rval = join("\n", $rv);
         }
         if ($indent > 0) {
             $rv = array();
             $rvalarr = explode("\n", $rval);
             $indentstr = str_repeat(' ', $indent);
             foreach ($rvalarr as $line) {
                 $rv[] = $indentstr . $line;
             }
             $rval = join("\n", $rv);
         }
         $rvals[] = $rval;
     }
     return join("\n", $rvals);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:47,代码来源:template.php

示例13: getRemoteIp

 static function getRemoteIp()
 {
     if (arr::hasKey($_SERVER, "REMOTE_ADDR")) {
         $ip = $_SERVER["REMOTE_ADDR"];
     } else {
         if (arr::hasKey($_SERVER, "HTTP_X_FORWARDED_FOR")) {
             $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
         } else {
             if (arr::hasKey($_SERVER, "HTTP_CLIENT_IP")) {
                 $ip = $_SERVER["HTTP_CLIENT_IP"];
             } else {
                 $ip = null;
             }
         }
     }
     return $ip;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:17,代码来源:dns.php

示例14: suid

 /**
  * @brief Suid to another user.
  * 
  * The aim of this function is to allow the user to become another user,
  * for testing or administrative purposes. It is similar to the sudo and
  * su commands in the *nix world.
  * 
  * A user can only suid ONCE, and is only allowed to switch back to the
  * previous (original) user by passing NULL as the user record.
  * 
  * @todo Thorougly test
  * @param UserRecord $user The user to suid to or null to revert
  * @return boolean True on success
  */
 static function suid(UserRecord $user = null)
 {
     $suid = (array) session::get(User::KEY_USER_SUID, null);
     if (arr::hasKey($suid, 'issuid') && $user == null) {
         // Can unsuid
         $uid = $suid['uid'];
         session::set(User::KEY_USER_AUTH, $uid);
         session::clr(User::KEY_USER_SUID);
         // user::set
         return true;
     } elseif ($user) {
         // Can suid
         session::set(User::KEY_USER_SUID, array('issuid' => true, 'uid' => user::getActiveUser()->userid, 'suid' => $user->userid));
         session::set(User::KEY_USER_AUTH, $user->userid);
         return true;
     } else {
         throw new SecurityException("Invalid suid attempt");
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:33,代码来源:user.php

示例15: __set

 function __set($property, $value)
 {
     if (!isset($this->properties)) {
         throw new RuntimeException("BasicContainer descendant doesn't have a protected variable properties");
     }
     if (arr::hasKey($this->properties, $property)) {
         if (is_array($this->properties[$property]) && !is_array($value)) {
             throw new RuntimeException("Attempting to assign non-array to array property");
         }
         $this->properties[$property] = $value;
     } else {
         throw new BadPropertyException("No such property: {$property}");
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:14,代码来源:structs.php


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